I've configured the basic Flask web sample in a VENV and now it is correctly published through IIS via FastCGI.
Well, here it is my trivial sample00.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello, World, from Flask!"
and the web.config, a little more involved:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule"
scriptProcessor="F:\Appl\flask\venv\Scripts\python.exe|F:\Appl\flask\venv\Lib\site-packages\wfastcgi.py"
resourceType="Unspecified" requireAccess="Script" />
</handlers>
</system.webServer>
<appSettings>
<add key="PYTHONPATH" value="F:\Appl\flask" />
<!-- Flask apps only: change the project name to match your app -->
<add key="WSGI_HANDLER" value="sample00.app" />
<add key="WSGI_LOG" value="F:\Appl\flask\wfastcgi.log" />
</appSettings>
</configuration>
After some trials and errors, I've discovered that I can enter in IIS Manager > Handler Mappings > select my "PythonHandler", edit the "Executable (optional)", and it checks if the path is correct and asks me to activate the handler, then I can answer "yes" and eventually it all works as expected.
So far so good. Now, I would like to setup it in IIS not as a separate website, but as a new application under another, existing, website. Is it even possible or is there a documentation saying that it is not permitted? We can close this question or mark it as duplicated, but till now I was not able to find a previous answer to this specific point. Anyway, I've tried to do that, but I receive a 404 page error... like if the request is not correctly forwarded to the cgi handler, hence I suspect there could be some problem in managing a Flask app at IIS application level, is it the case or what else am I doing wrong?