1 from flask import Flask,render_template 2 from flask import request 3 app = Flask(__name__) 4 5 @app.route(‘/‘,methods=[‘GET‘,‘POST‘]) 6 def home(): 7 return render_template(‘home.html‘) 8 9 @app.route(‘/signin‘,methods=[‘GET‘]) 10 def signin_from(): 11 return render_template(‘form.html‘) 12 @app.route(‘/signin‘,methods=[‘POST‘]) 13 def signin(): 14 username = request.form[‘username‘] 15 password = request.form[‘password‘] 16 if username==‘admin‘ and password==‘password‘: 17 return render_template(‘signin_ok.html‘,username=username) 18 return render_template(‘form.html‘,message=‘bad username or password‘,username=username) 19 20 if __name__ ==‘__main__‘: 21 app.run()
时间: 2024-10-12 22:57:29