我正在使用flask框架来呈现网站并获取数据。这是webtool.py。问题在于wsgi脚本,因为python脚本自己编译并运行文件,显示在localhost:5000上。但是当我尝试使用wsgi脚本提供它时,它只显示我的目录中的文件列表,而不是脚本。
from flask import Flask
from flask import request
from flask import render_template
app = Flask(__name__)
@app.route('/')
def my_form():
return render_template("index.html")
@app.route('/', methods=['POST'])
def my_form_post():
text1 = request.form['inputDate']
target = open('tmp', 'w')
target.write(text1)
if __name__ == '__main__':
app.run()
这是sites-availible.conf
<VirtualHost *:80>
ServerName www.test.com
WSGIDaemonProcess webtool user=main group=sudo threads=5 home=/var/www/html/Pandacovers
WSGIScriptAlias / /var/www/html/Pandacovers/webtool.wsgi
<Directory /var/www/html/Pandacovers>
WSGIProcessGroup webtool
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
这是webtool.wsgi
import sys
sys.path.append('/var/www/html/Pandacovers')
from webtool import app as application