-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflask_2_app.py
45 lines (32 loc) · 909 Bytes
/
flask_2_app.py
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
37
38
39
40
41
42
43
44
45
from flask import Flask, url_for
from markupsafe import escape
from flask import request
import time
app = Flask(__name__)
@app.route('/')
def index():
return 'index'
@app.route('/login')
def login():
print('POST') if request.method == 'POST' else print("GET")
print(dir(request))
# try:
# for v in dir(request):
# print(getattr(request, v))
# # time.sleep(1)
# except Exception:
# print('error')
return 'login'
@app.route('/user/<username>')
def profile(username):
return '{}\'s profile'.format(escape(username))
@app.route('/about/1/2/3')
def about():
return 'about us'
with app.test_request_context():
print(url_for('index'))
print(url_for('login'))
print(url_for('login', next='/'))
print(url_for('profile', username='dow'))
print(url_for('about'))
print(url_for('static', filename='style.css'))