httpplatformhandler running flask application quits unexpectedly without clear errors

67 views Asked by At

I've run my flask application locally through IIS with FastCGI for quite a while, but am trying to do so using httpPlatform with IIS on a Windows Server 2022 image from EC2 for production deployment (since FastCGI says it isn't being maintained any more). I have been beating my head against the wall trying to figure out what is wrong. I've given up trying to get my actual application to run and am simply trying to get httpplatformhandler to run a "Hello World" Flask app.

Here is the app directory for this test app: C:\inetpub\wwwroot\test\test.py C:\inetpub\wwwroot\test\web.config

Contents of web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" scriptProcessor="C:\Program Files\Python311\python.exe| c:\inetpub\wwwroot\test\test.py" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
    <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\test.log" startupTimeLimit="20" processPath="C:\Program Files\Python311\python.exe" arguments=".\test.py">
            <environmentVariables>
                <environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
            </environmentVariables>
        </httpPlatform>
        <tracing>
            <traceFailedRequests>
                <add path="*">
                    <traceAreas>
                        <add provider="ASP" verbosity="Verbose" />
                        <add provider="ISAPI Extension" verbosity="Verbose" />
                        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,F    astCGI,WebSocket" verbosity="Verbose" />
                    </traceAreas>
                    <failureDefinitions statusCodes="500-600" />
                </add>
            </traceFailedRequests>
        </tracing>
  </system.webServer>
</configuration>

end config file

Contents of test.py app

from flask import Flask

app = Flask(__name__)

@app.route('/')
def main():
    return "Hello World"

I tried using "C:\Program Files\Python311\python.exe" for the scriptProcessor as well without success (adding the piped in test.py was something that worked with FastCGI for me so I figured I'd try it out).

I have looked for tutorials, and stackoverflow posts, and a number of places without getting much more in terms of suggestions. I saw a lot of comments about making sure that IIS users have correct permissions, which is always a worthwhile reminder. However, the "IIS AppPool\DefaultAppPool" and "IIS_IUSRS" both have read/execute to the Python311 folder and read/write/execute to the inetpub\wwwroot\test folder so I think should be ok.

0

There are 0 answers