I'm trying to get a very basic flask app to work on IIS 10 running on Windows Server 2019. I followed the HTTPPlatform Handler instructions from: https://docs.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2019
But I keep getting HTTP 500.19 errors with error code 0x8007000d. From googling, I suspect the problem is in my web.config, but I don't know what is wrong. The app works fine from the command line. This is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="D:\python39\python.exe"
arguments="D:\inetpub\wwwroot\flasktest.py"
stdoutLogEnabled="true"
stdoutLogFile="d:\logs\python.log"
startupTimeLimit="60"
processesPerApplication="16">
<environmentVariables>
<environmentVariable name="SERVER_PORT" value="9010" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
from flask import Flask, render_template
app = Flask(__name__)
#app.debug = True
@app.route("/", methods=('GET', 'POST'))
def home():
return render_template('main.html', hello = 'hello world')
if __name__ == '__main__':
app.run(host='0.0.0.0',port=9010)
this is my main.html
{% extends 'layout.html' %}
{% block content %}
<div class="container">
<div class="leftrow1">
{{ hello }}
</div>
<div class="leftrow2">
</div>
<div class="leftrow3">
</div>
<div class="leftrow4">
</div>
<div class="main_frame_1">
</div>
<div class="main_frame_2">
</div>
</div>
{% endblock content %}
and this is the layout.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="/static/css/style.css"/>
</head>
<body>
{% block content %}
{% endblock content %}
</body>
It seems that you don't have the correct permission to access D:\python39\python.exe and D:\inetpub\wwwroot\flasktest.py.
Open IIS Manager -> Select the site you added the HttpPlatformHandler
Click Handler Mappings in the feature view -> select the HttpPlatformHandler
Click Edit Feature Permission in the Action Panel
Make sure you have check the Execute permission
User contributions licensed under CC BY-SA 3.0