|
@@ -2,25 +2,13 @@ from flask import Flask
|
|
|
from flask import request
|
|
|
from flask import make_response
|
|
|
from flask import redirect
|
|
|
+from flask import render_template
|
|
|
app=Flask(__name__)
|
|
|
|
|
|
@app.route('/')
|
|
|
def index():
|
|
|
- method=request.method
|
|
|
- user_agent=request.headers['User_Agent']
|
|
|
- return '请求方法为%s<br>你的UA为%s' % (method,user_agent)
|
|
|
+ return render_template('index.html')
|
|
|
|
|
|
-@app.route('/404')
|
|
|
-def return404():
|
|
|
- return '404 not found',404
|
|
|
-
|
|
|
-@app.route('/login')
|
|
|
-def login():
|
|
|
- response=make_response('登录成功,并记住密码!')
|
|
|
- response.set_cookie('username','Felix')
|
|
|
- response.set_cookie('pw_hash','d45...ae17f')
|
|
|
- return response
|
|
|
-
|
|
|
-@app.route('/baidu')
|
|
|
-def baidu():
|
|
|
- return redirect('https://www.baidu.com')
|
|
|
+@app.route('/hello/<user>')
|
|
|
+def hello(user):
|
|
|
+ return render_template('hello.html',user=user)
|