Reputation: 63
I've hosted a flask app on Azure, but there seems to be some problem with linking the WSGIHandler. It is a very simple bug. I can't seem to identify it. The following is the error I'm getting in my Logs
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "D:\Python27\Scripts\wfastcgi.py", line 711, in main
env, handler = read_wsgi_handler(response.physical_path)
File "D:\Python27\Scripts\wfastcgi.py", line 568, in read_wsgi_handler
return env, get_wsgi_handler(handler_name)
File "D:\Python27\Scripts\wfastcgi.py", line 551, in get_wsgi_handler
raise ValueError('"%s" could not be imported' % handler_name)
ValueError: "App" could not be imported
StdOut:
StdErr:
ErrorCode Access is denied.
(0x5)
Here is my folder structure
myapplication
-- App
-- __init__.py
The contents of __init__.py
is
from flask import Flask
# initialize the flask app
app = Flask(__name__)
print "init"
@app.route('/')
def hello():
return "hello world";
if __name__ == "__main__":
app.run()
I've configured the following App Settings in Azure Web App
PYTHONPATH = D:\home\site\wwwroot
WSGI_HANDLER = App.app
Upvotes: 4
Views: 1717
Reputation: 13918
Per my understanding, your deployment is incompleteness, as Azure uses IIS to host python web sites on Web Apps Services, which needs a web.config to configure hander mapping and URL rewrite rules and some other settings.
To create and deploy a flask project on Azure Web Apps , we can generally follow the steps below:
1, On Azure manage portal, click NEW => COMPUTE => WEB APP =>FROM GALLERY at the bottom navigation, on the ADD WEB APP dialog, select Flask, name the site on the next dialog page. Now we have created a flask web site project.
We can type the endpoint on the browser to check the website,
http://<your_site_name>.azurewebsite.net
2,On the web apps list, click the name we created above to get into the configuration page, click DASHBOARD, at the quick glance column, click Set up deployment from source control ,select Local Git repository. Now there is an additional tab named DEPLOYMENT beside the DASHBOARD tab. And in the DEPLOYMENT page there are steps of how to deploy your site by git. We can clone the project to local by the GIT URL provided on this page.
We can get more on this official article
Upvotes: 0