【发布时间】:2021-04-13 16:40:28
【问题描述】:
我的 Python Flask/CGI 程序不断收到500 Internal Server Error。
我在共享主机上运行它,所以我遵循了这个教程: https://medium.com/@dorukgezici/how-to-setup-python-flask-app-on-shared-hosting-without-root-access-e40f95ccc819
这是我的主要 python 脚本:(~/website/mainApp.py)
from flask import Flask
app = Flask(__name__)
@app.route("/")
def home():
return "123 :)"
if __name__ == "__main__":
app.run()
这是我的 CGI 脚本 (~/website/main.cgi)
#!/usr/bin/python
import sys
sys.path.insert(0, "~/.local/lib/python3.7/site-packages")
from wsgiref.handlers import CGIHandler
from mainApp import app
CGIHandler().run(app)
这是我的 .htaccess 文件 (~/website/.htaccess):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /main.cgi/$1 [L]
这是我得到的错误:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
有谁知道哪里可能出错了?
谢谢!
编辑:它现在有一个奇怪的.pyc 文件。但是我没有添加它。?
【问题讨论】:
-
顺便说一句,您可以放心地忽略
.pyc文件,这只是 Python 生成的字节码。
标签: python apache flask cgi ionos