利用flask 实现简单模版站

 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()

 

posted @ 2017-02-10 11:59  Erick-LONG  阅读(358)  评论(0编辑  收藏  举报