在Xampp中使用cgi腳本部署Flask應用程序( a Flask using cgi in Xampp)
我正試圖在XAMMP上部署一個簡單的Hello World腳本 。
如果鏈接被刪除,則為
application.py
:from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!"
我的.cgi腳本如下所示:
#!C:/Users/Simon/Documents/Python/Scripts/python.exe from wsgiref.handlers import CGIHandler from application import hello CGIHandler().run(app)
C:/Users/Simon///是我的虛擬環境的位置。
我以如下方式配置了XAMMP(httpd.conf):
AddHandler cgi-script .py ScriptInterpreterSource Registry-Strict
我一直保留這種配置。
我按照文檔中的建議嘗試了以下內容 :
ScriptAlias /Network C:/Users/Simon/Documents/Network/application.cgi
這失敗了,我嘗試了這個建議在這里 :
Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted Alias /Network "C:/Users/Simon/Documents/Network"
在所有情況下,Error 500 error! 返回。
我不確定是否需要yy打不開提示應用程序配置不正確怎么辦,但在.log顯示相關錯誤:
192.168.0.8 - - [17/Feb/2018:13:21:12 +0000] "GET / HTTP/1.1" 500 1100 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36"
如果有什么遺漏,請告訴我,我會添加它。
我如何正確配置我的服務器yy打不開提示應用程序配置不正確怎么辦,以便我可以運行此腳本?
.cgi中有錯誤:
#!C:/Users/Simon/Documents/Python/Scripts/python.exe from wsgiref.handlers import CGIHandler from application import hello CGIHandler().run(hello)
但它仍然返回一個錯誤:
發生服務器錯誤。 請聯系管理員。
I am to a Hello World on XAMMP.
In case the link is here is .py:
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!"
My .cgi is as :
#!C:/Users/Simon/Documents/Python/Scripts/python.exe from wsgiref.handlers import CGIHandler from application import hello CGIHandler().run(app)
C:/Users/Simon/// is the of my .
I have XAMMP (httpd.conf) in the way:
AddHandler cgi-script .py ScriptInterpreterSource Registry-Strict
This I kept in all cases.
I tried the as :
ScriptAlias /Network C:/Users/Simon/Documents/Network/application.cgi
This and I tried this as in here:
Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted Alias /Network "C:/Users/Simon/Documents/Network"
In all cases an Error 500 error! was .
I'm not sure if it's but here is the error in .log:
192.168.0.8 - - [17/Feb/2018:13:21:12 +0000] "GET / HTTP/1.1" 500 1100 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36"
If is tell me and I will add it.
How can I my so that I can run this ?
There was in .cgi:
#!C:/Users/Simon/Documents/Python/Scripts/python.exe from wsgiref.handlers import CGIHandler from application import hello CGIHandler().run(hello)
It is still an error:
A error . the .
原文: