Reputation: 2606
I am new to python and I try to deploy a simple hello python application on IIS and I followed this URL
https://support.sisense.com/hc/en-us/community/posts/115007362727-Installing-Python-on-IIS
Hello.py
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program</h2>'
print '</body>'
print '</html>'
However, it error's as mentioned below
HTTP Error 401.3 - Unauthorized
You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server
I feel the issue may not be related to permission as I am able to browse hello.html
I tried some of the solutions provided in SO to resolve the issue but nothing worked. Any help is highly appreciated
Upvotes: 5
Views: 4756
Reputation: 12814
To configure Python with IIS you can try to follow the below steps:
https://www.python.org/downloads/windows/
hello.py
file:print("Content-type:text/html\r\n\r\n")
print('<html>')
print('<head>')
print('<title>Hello Word - First CGI Program</title>')
print('</head>')
print('<body>')
print('<h2>Hello Word! This is my first CGI program</h2>')
print('</body>')
print('</html>')
*.py
, and map it to c:\Python37-32\python.exe %s %s
.
Make sure directory browsing is enabled.
web.config
file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="python" path="*.py" verb="*" modules="CgiModule" scriptProcessor="C:\Python37-32\python.exe %s %s" resourceType="File" />
</handlers>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
Set iis_iusrs
and iusr
permission to the site folder(c:\pythonapp
) and python folder(C:\Python37-32
).
Make sure anonymous authentication is enabled, and the application pool is set to the application pool identity.
After making all the changes restart IIS server and browse the site.
Upvotes: 5