1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| from flask import Flask,render_template,request import datetime app = Flask(__name__)
@app.route('/index') def hello_world(): return 'Hello World!'
@app.route('/user/<name>') def welcome(name): return "welcome %s"%name
@app.route('/user/<int:id>') def welcomeid(id): return "welcome num %d"%id
@app.route("/") def index2(): list = ["l1","l2","l3"] time = datetime.date.today() task = {"task":"clean","time":"3hours"} return render_template("index.html",var = time,list = list, task = task)
@app.route('/register') def register(): return render_template("register.html")
@app.route('/result',methods=['POST','GET']) def result(): if request.method == 'POST': result = request.form return render_template("result.html",result = result)
if __name__ == '__main__': app.run(debug=True)
|