刚接触到蟒蛇。以下是使用Python3.6.7、烧瓶、Gunicorn、NGINX和MySQL在Ubuntu18.04上为应用程序(MySQL)服务的几个教程
这些教程是:
和
我通过了第一个教程,并能够成功地服务于第二个教程中的基本网页。
在虚拟环境中安装所有的东西,然后使用pip install flask-mysql安装烧瓶-mysql。
我的笔尖冻结显示:
Click==7.0
Flask==1.0.2
Flask-MySQL==1.4.0
itsdangerous==1.1.0
Jinja2==2.10
MarkupSafe==1.1.0
PyMySQL==0.9.3
Werkzeug==0.14.1在安装Flask-MySQL之后,我通过尝试以下不同版本的"from“命令(在python提示符下)来测试安装:
from flask.ext.mysql import MySQLfrom flaskext.mysql import MySQLfrom flask_mysql import MySQLfrom flaskext.mysql import MySQL1、2和3都生成ModuleNotFoundError... --唯一不抛出错误的是from flaskext.mysql import MySQL
但是,当我将from flaskext.mysql import MySQL添加到我的烧瓶应用程序文件(app01.py)中时,我立即得到一个502错误的网关错误。我的app01.py文件是
from flask import Flask, render_template, json, request
#from flaskext.mysql import MySQL #<--comment out or get 502 error
hello = Flask(__name__)
@hello.route("/")
def greeting():
return render_template('index.html')
@hello.route('/showSignUp')
def showSignUp():
return render_template('signup.html')
@hello.route('/signUp',methods=['POST'])
def signUp():
# read the posted values from the UI
_name = request.form['inputName']
_email = request.form['inputEmail']
_password = request.form['inputPassword']
# validate the received values
if _name and _email and _password:
return json.dumps({'html':'<span>All fields good !!</span>'})
else:
return json.dumps({'html':'<span>Enter the required fields</span>'})
if __name__ == "__main__":
hello.run(host='0.0.0.0')任何帮助使502错误消失,以便我连接到数据库是非常感激的。谢谢。
发布于 2019-02-22 01:58:08
这可能是virtualenv错误,请查看以下链接:https://www.pythonanywhere.com/forums/topic/2877/
https://stackoverflow.com/questions/54817890
复制相似问题