Python FastCGI error on Microsoft Azure -
trying deploy python app on azure cloud. created webapp cookiecutter template python3.5.2x64. using preconfigured web.config
template faced 500 error:
<handler> scriptprocessor not found in <fastcgi> application configuration
.
my web.config
file:
<configuration> <system.web> <customerrors mode="off"/> </system.web> <appsettings> <add key="pythonpath" value="d:\home\site\wwwroot"/> <add key="wsgi_handler" value="webapp.wsgi_app"/> <add key="wsgi_log" value="d:\home\logfiles\python.log"/> </appsettings> <system.webserver> <httperrors errormode="detailed" /> <modules runallmanagedmodulesforallrequests="true" /> <handlers> <add name="python fastcgi" path="*" verb="*" modules="fastcgimodule" scriptprocessor="d:\home\python35\python.exe|d:\home\python35\wfastcgi.py" resourcetype="unspecified" requireaccess="script" /> </handlers> </system.webserver> </configuration>
my webapp.py
:
def wsgi_app(environ, start_response): status = '200 ok' response_headers = [('content-type', 'text/plain')] start_response(status, response_headers) response_body = 'hello world' yield response_body.encode() if __name__ == '__main__': wsgiref.simple_server import make_server httpd = make_server('localhost', 5555, wsgi_app) httpd.serve_forever()
using django app azure doesn't help, because it's rather outdated (uses unsupported microsoft.diagnostics
, raises attributeerror: 'module' object has no attribute 'get_virtualenv_handler'
).
any suggestions i'm doing wrong? thank you.
update. after time spent i've found out works native installed python (2 or 3, doesn't matter), seems iis doesn't see or smth python extension (installed azure portal btw). nevertheless, native python works not immediately, @ first throwing typeerror: source code string cannot contain null bytes
(python 3.4) or attributeerror: 'module' object has no attribute 'wsgi_app'
(python 2.7). , after 15 minutes magically starts working. doing changing hello world! string.
nah, solution pretty logical not obvious (as think). added handler web app settings on azure portal (web app -> application settings -> handler mappings) , worked charm!
Comments
Post a Comment