I am trying to run a python script (adsb-exchange.py) on an Apache httpd webserver running on an EC2 instance. The script runs perfect from the AWS CLI, but when I try and run from a simple html page off the server I get:
Internal Server Error 500 - The server encountered an internal error or misconfiguration and was unable to complete your request.
Note, running a simple 'hello.py' script from the html page works fine.
Everything is added under the /var/www/html directory and the httpd.conf file is updated to reflect the DocumentRoot path.
Index.html file:
<h1>Welcome!</h1>
<p>Click the button below to start running the scipt...</p>
<form action="/adsb-exchange.py" method="post">
<button>Start</button>
</form>
adsb-exchange.py file:
#!/usr/bin/python
#!/usr/bin/env python
#import Python modules
import cgi
import sys
cgi.enable()
print "Content-type: text/html\n\n"
print
#application imports
import modules.get_config_vals as cfgvals
import modules.adsb_pull as ap
import modules.json2csv as j2c
#get payload params from adsb_config file
payload = cfgvals.get_payload()
#get the JSON pull frequency and runtime from config file
adsb_freq = cfgvals.get_pullfreq()
#send to adsb_pull module, create a JSON object file, and get the filename returned
f = ap.pull_data(payload, adsb_freq)
#convert JSON object file to CSV, output CSV file to directory
j2c.j2csv(f)
raw_input("Press Enter to exit")
The adsb-exchange.py file makes calls to various modules under the 'modules' folder via the /var/www/html/modules path, and each module includes the lines: print "Content-type: text/html\n\n" print
GET and POST methods do not appear to impact the results. Output files are dumped to the same directory as adsb-exchange.py is in, for now.
Again, the script runs when executed directly from the ACL, but not when it is called from the index.html page.
Thanks!