I am learning Python, so I am teaching myself with very simple Python scripts, or at least trying to do so.
While my Python scripts run just fine via command-line, I would like to implement them on my IIS web server and view them as a web page. I have set it up so that I have a FastCGI module pointing to C:\Python313\python.exe %s %s and I also have downloaded and installed wfastcgi and point to that in the FastCGI handler mapping for all *.py files
helloworld.py:
print('Content-Type: text/plain')
print('')
print('Hello, world!')ode here
It looks like you’ve tried to follow a StackOverflow answer (“Python on IIS: how?”), except it doesn’t even mention wfastcgi - which, however, is mentioned in another answer in that very thread. As per the documentation, the wfastcgi itself requires an explicit handler, such as -
- which is nowhere to be found in your own helloworld.py.
I’m not by no means an expert on IIS/FastCGI myself, yet perhaps it might make a bit more sense to find and stick to just one approach/tutorial for this - from start to finish?
I wound up going to several different sources to try to figure this out, all to no avail. Nothing I found online works for me.
Latest I did was to put a web.config in my C:\inetpub\wwwroot\cma folder where the HTML and Python scripts are and tried that way. I now get a 500.19 Internal Server Error with its inability to find web.config
Did you try following the official guide from Microsoft? At no point does it seem to mention that simply writing to stdout / print() is enough: every example mentioned, instead, seems to refer to some established framework (bottle/flask/django). Your server config might be expecting a proper entry point, that your helloworld.py doesn’t have.
From the documentation:
<!-- The handler here is specific to Bottle; see the next section. -->
<add key="WSGI_HANDLER" value="app.wsgi_app()"/>
I completely gave up on this approach. I will probably never understand how to do this, so I am starting completely over via PyScript . I signed up online and got a project with an index.html, a main.py, and a pyscript.toml. I copied them to my C:\inetpub\wwwroot\cma , reconfigured pyscript.toml to be pyscript.json instead, and it still doesn’t work.
I then tried running via [quote]python -m http.server[/quote] as administrator on the /cma folder and pulling up the URL with port 8000, only to get this:
Error response
Error code: 404
Message: File not found.
Error code explanation: 404 - Nothing matches the given URI.
How is your server supposed to know about your app - if all you’re doing is trying to print() to stdout? Do you understand the basics of back-end development, to begin with?
I complete gave up. I can’t do Python like other people can so easily do. I went to one other PyScript tutorial and tried a very simple method to handle using Python as a script, and it is finally working for me.
I couldn’t use Flask at all, and the multitude of tutorials made things even more confusing to me.
Maybe they’re right online when they say that Python is too hard to learn.