I would like to host my Flask API in sub-directory on IIS.
MYLAPTOP (IIS Server)
|
|____Sites
|
|____Default Web Site (Website)
|
|____service (Virtual Directory)
|
|____payrollapi (Application)
The URL for the payrollapi is http://localhost/service/payrollapi/
I configured the wfastcgi and and FastCGI settings
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="FlaskHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="c:\annaconda\envs\payroll\python.exe|c:\annaconda\envs\payroll\lib\site-packages\wfastcgi.py" resourceType="Unspecified" />
</handlers>
</system.webServer>
<appSettings>
<add key="WSGI_HANDLER" value="payroll.app" />
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\service\payrollapi" />
</appSettings>
</configuration>
Flask API Script:
from flask import Flask
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def notes_list():
return "Welcome to Payroll !"
if __name__ == "__main__":
app.run(debug=True)
It returns the error code "HTTP Error 403.18 - Forbidden
" while on trying to access the API method.
I tried with URL Rewrite also but there is no use
<system.webServer>
<directoryBrowse enabled="true" />
<rewrite>
<rules>
<rule name="Reverse Proxy to payroll" stopProcessing="true">
<match url="^service/payrollapi/(.*)" />
<action type="Rewrite" url="http://localhost:5500/service/payrollapi/{R:1}" />
</rule>
</rules>
</rewrite>
Kindly assist me how to deploy the Flask application in Sub-direcory / sub-application in a website.