一个demo
程序员文章站
2022-04-24 10:51:35
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body charset="UTF-8">
<form action="/login" method="post">
username:<input type="text" name="username">
password:<input type="password" name="password">
<input type="submit" value="login">
</form>
{{get_flashed_messages()[0]}}
</body>
</html>
html模板
# -*- coding: utf-8 -*-
from flask import Flask, request ,flash
from flask import render_template
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
app = Flask(__name__)
app.secret_key="123"
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
form=request.form
username=form.get('username')
password=form.get('password')
if not username:
flash('用户名为空')
return render_template('login.html')
if not password:
flash('密码为空')
return render_template('login.html')
else:
return render_template('login.html')
flask的路由逻辑 加入了flask闪现
上一篇: tp5 多对多关联操作
下一篇: 4.SSM整合_多表_多对多的增删改查