这是我的 app.py 代码:from flask import Flaskapp = Flask(__name__)from flask import redirect, render_template as rt, url_for, request, flashimport sqlite3from sqlite3 import Errorcon = sqlite3.connect('database.db')@app.route('/')def nullPage(): return redirect('/home/')@app.route('/home/')def homePage(): return rt('homePage.html')@app.route('/home/signup/', methods=["get", "post"])def signUp(): return rt('signUp.html')@app.route('/home/login/', methods=["get", "post"])def logIn(): return rt('logIn.html')@app.route('/home/logedin/', methods=["get", "post"])def verLogIn(): if request.method == 'post': passW = request.form['pass'] email = request.form['email'] try: sql_table(con) return "Thanks for loging in!" except Error: print(Error) flash( "An error has occured when talking to the database. Please try again later! Thank you for understanding.", category='error')def sql_table(con): cursorObj = con.cursor() cursorObj.execute( "CREATE TABLE credentials(id integer PRIMARY KEY, email text, passWord text)" ) con.commit() return print("Commited")if __name__ == "__main__": app.secret_key = 'super secret key' # app.config['SESSION_TYPE'] = 'filesystem' # sess.init_app(app) app.debug = True app.run() # print("Bye world")```这是我调用POST方法代码的html代码: <!-- @format --> {% extends 'base.html' %} {% block head %} <div></div> <link rel="stylesheet" href="{{ url_for('static', filename='stylesheets/home.css') }}" /> {% endblock %} {% block body %} <header> <h1> Hi, welcome to the WebEmailApp </h1> </header> {% endblock %}
1 回答
RISEBY
TA贡献1856条经验 获得超5个赞
你的logedin路线需要返回一些东西。
@app.route('/home/logedin/', methods=["get", "post"])
def verLogIn():
if request.method == 'post':
passW = request.form['pass']
email = request.form['email']
try:
sql_table(con)
except Error:
print(Error)
flash(
"An error has occured when talking to the database. Please try again later! Thank you for understanding.",
category='error')
return rt('yourtemplate.html') # <---- here
- 1 回答
- 0 关注
- 113 浏览
添加回答
举报
0/150
提交
取消