Python Forum
500 Internal Server error trying to run external Python script via HTML
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
500 Internal Server error trying to run external Python script via HTML
#1
I am running a very simple HTML script on IIS 10.0 using Brython to communicate with a Python script.

HTML:

<html>
<!-- Based on https://anvil.works/blog/python-in-the-browser-talk -->
<head>
	<script src="pages/scripts/libz/brython-3.7.5.min.js"></script>
</head>
<body onload="brython(1)">
    <script type="text/python" src="python_test.py"></script>
    <form>
	    <input id="name-box" placeholder="Enter your name">
	    <button id="greet-button">Say Hello</button>
    </form>
</body>
</html>
Python:
import document, alert
def greet(event):
	alert("Hello " + document["name-box"].value + "!")

document["greet-button"].bind("click", greet)
I added Python as FastCGI module in my module mappings in IIS, and I also installed wfastcgi and included the path to its .exe within the module mapping and restarted IIS.

I still have a 500 Internal Server error:

Quote:Error occurred while reading WSGI handler:

Traceback (most recent call last):
File "C:\Python313\Lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python313\Lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "C:\Python313\Lib\site-packages\wfastcgi.py", line 586, in get_wsgi_handler
raise Exception('WSGI_HANDLER env var must be set')
Exception: WSGI_HANDLER env var must be set


StdOut:

StdErr:

I am unsure as to what I may have missed or have one wrong. Any help appreciated.

Thanks
Reply
#2
Ok it went now to a 502 Bad Gateway error, and in spite of doing everything I could find online to fix the problem, the 502 persists, and nothing happens

HTML:
<html>
<!-- Based on https://anvil.works/blog/python-in-the-browser-talk -->
<head>
	<script src="scripts/libz/brython-3.7.5.min.js"></script>
</head>
<body onload="brython(1)">
    <script type="text/python" src="scripts/python_test.py"></script>
    <form>
	    <input id="name-box" placeholder="Enter your name">
	    <button id="greet-button">Say Hello</button>
    </form>
</body>
</html>
Python:
try:
	import document, alert
	def greet(event):
		alert("Hello " + document["name-box"].value + "!")

	document["greet-button"].bind("click", greet)
except NameError:
	print("Name Error")
except:
	print("Some other kind of error")
I did the following as well:

1) Added C:\users\me\AppData\Roaming\Python\Python313 to "Path" environmental variable
2) Added C:\users\me\AppData\Roaming\Python\Python313\Scripts to "Path" environmental varialbe
3) Restarted laptop
4) pip install document
5) pip install alert
6) Made sure that IIS contains a module mapping to *.py to go to C:\Python313\python.exe as CgiModule and removed all restrictions
7) Restarted IIS
8) Python version is 3.1.3

At this point I am out of ideas and could really use help to get even this very simple program to work on IIS. Help appreciated.

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Script does not work on Linux server scrapemasta 0 1,222 Mar-22-2024, 11:07 AM
Last Post: scrapemasta
  Server Error with parse_args() using Flask NoNameoN 0 1,666 Jul-30-2022, 09:42 AM
Last Post: NoNameoN
  [split] flask 500 internal server error DarthTensor 3 5,326 Nov-11-2021, 06:10 AM
Last Post: DarthTensor
  deploying python script on a server rickyrt 0 1,976 Aug-31-2021, 04:03 PM
Last Post: rickyrt
  HTML multi select HTML listbox with Flask/Python rfeyer 0 6,133 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  TDD/CSS & HTML testing - CSS selector (.has-error) makoseafox 0 2,342 May-13-2020, 07:41 PM
Last Post: makoseafox
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 3,135 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning
  BeautifulSoup: Error while extracting a value from an HTML table kawasso 3 4,224 Aug-25-2019, 01:13 AM
Last Post: kawasso
  [Flask] html error 405 SheeppOSU 0 2,942 Jun-08-2019, 04:42 PM
Last Post: SheeppOSU
  html error 404 SheeppOSU 1 2,721 Jun-03-2019, 02:19 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020