1

500 Internal Server ErrorPython Flask/CGI プログラムでを受け取り続けています。

私は共有ホスティングで実行しているので、次のチュートリアルに従いました: 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]

これは基本的にそのファイル ツリーです。 ファイルツリー2.0のイメージ

これは私が得ているエラーです:

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ファイルが含まれるようになりました。私はそれを追加しませんでした。

4

2 に答える 2

1

main.cgiファイルの先頭にあるシバンを変更したところ、うまくいきました。

前: #!/usr/bin/python

後: #!/usr/bin/python3.7

于 2021-01-08T13:33:19.780 に答える