利用flask 实现简单模版站

时间:2022-01-18 13:52:29
 from flask import Flask,render_template
from flask import request
app = Flask(__name__) @app.route('/',methods=['GET','POST'])
def home():
return render_template('home.html') @app.route('/signin',methods=['GET'])
def signin_from():
return render_template('form.html')
@app.route('/signin',methods=['POST'])
def signin():
username = request.form['username']
password = request.form['password']
if username=='admin' and password=='password':
return render_template('signin_ok.html',username=username)
return render_template('form.html',message='bad username or password',username=username) if __name__ =='__main__':
app.run()