问题描述
我已经使用Flask进行开发了一段时间,但最近决定解决“此服务器不应用于生产”的警告。我花了几个小时试图让wsgi无效。
这是我的/ var / www的结构:
webApp
webApp
static
templates
__init__.py
webapp.wsgi
#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/webApp/")
from webApp import app as application
application.secret_key = 'Add your secret key'
我的webApp.conf文件:
<VirtualHost *:80>
ServerName my_vps_ip
ServerAdmin [email protected]
WsgiScriptAlias / /var/www/webApp/webapp.wsgi
<Directory /var/www/webApp/webApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/webApp/webApp/static
<Directory /var/www/webApp/webApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
from flask import Flask
app = Flask(__name__)
@app.route('/',methods = ['GET'])
def test():
return 'test'
if __name__ == '__main__':
app.run()
当我访问服务器IP时会发生这种情况:
为什么会这样?我花了整整一天的时间来弄清楚这个问题,因此对您的帮助表示感谢!
解决方法
可以请您检查serverName是否正确,并且应该是注册域。