尝试在网络浏览器上运行python脚本,但出现500个内部服务器错误

时间:2019-12-25 09:46:29

标签: python html rhel7 python-webbrowser

这是我的python脚本,在命令行上运行良好,但是当我将其放在 / var / www / cgi-bin 目录中时,使其可执行并尝试通过浏览器运行,显示错误:

  

500内部服务器错误。

我正在使用rhel 7.5。

#!/usr/bin/python36
import cgi
import pandas
from pandas.io.json import json_normalize
import requests

form =cgi.FieldStorage()
print("Content-Type: text/html")
print("") 
r = requests.get(url='http://www.bom.gov.au/fwo/I`enter code here`DN60801/IDN60801.94596.json')
f = r.json()

for value in f.values():
    d = value["data"]

    with pandas.option_context('display.max_rows', None, 'display.max_columns', None):
        data = pandas.DataFrame(json_normalize(d))
        x=pandas.DataFrame(data.drop(columns=["sort_order","wmo","history_product","local_date_time_full","aifstime_utc","lat","lon","cloud_base_m","cloud_oktas","cloud_type","press_qnh","press_tend","rel_hum","name","sea_state"]))

        print(x)


print("Mean temprature is ",x.loc[:,"air_temp"].mean())
print("Max temprature is ",x.loc[:,"air_temp"].max())
print("Min temprature is ",x.loc[:,"air_temp"].min())

这是我尝试运行此脚本的简单HTML脚本。

<!DOCTYPE html>
<html>
<body>
<form action= "/cgi-bin/test.py" method='GET'>
<h1>"click on button to show the result</h1>
<input type="submit" value="click here" />
</form>
</body>
</html>

注意:我制作了一个简单的脚本(如计算器)进行检查,它们在Web浏览器上运行顺利。

0 个答案:

没有答案