1
2
3
4
5
6
7
|
[root@web02 flask]
# python hell
* Running on http:
//0
.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 190-507-621
1.89.202.74 - - [07
/Feb/2017
20:11:49]
"GET / HTTP/1.1"
200 -
1.89.202.74 - - [07
/Feb/2017
20:11:49]
"GET /favicon.ico HTTP/1.1"
404 -
|
1
2
3
4
5
6
7
8
9
10
|
[root@web02 flask]
# cat hell
from flask
import
Flask
app = Flask(__name__)
@app.route(
'/'
)
def hello_world():
return
'Hello World!'
if
__name__ ==
'__main__'
:
app.debug = True
app.run(host=
'0.0.0.0'
)
[root@web02 flask]
#
|
2.
1
2
3
4
5
6
7
8
|
[root@web02 flask]
# python helloflask
* Running on http:
//0
.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 190-507-621
1.89.202.74 - - [07
/Feb/2017
20:14:27]
"GET / HTTP/1.1"
200 -
1.89.202.74 - - [07
/Feb/2017
20:14:55]
"GET /hello/xiaoming HTTP/1.1"
200 -
101.226.89.119 - - [07
/Feb/2017
20:15:05]
"GET /hello/xiaoming HTTP/1.1"
200 -
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@web02 ~]
# cat flask/helloflask
from flask
import
Flask
app = Flask(__name__)
@app.route(
'/'
)
def hello_world():
return
'Hello World!'
@app.route(
'/hello/<username>'
)
def hello(username):
return
'hello %s'
%username
if
__name__ ==
'__main__'
:
app.debug = True
app.run(host=
'0.0.0.0'
)
[root@web02 ~]
#
|
3.
1
2
3
4
|
[root@web02 flask]
# python id
* Running on http:
//0
.0.0.0:5000/ (Press CTRL+C to quit)
1.89.202.74 - - [07
/Feb/2017
20:23:52]
"GET /hello/1 HTTP/1.1"
200 -
101.226.85.67 - - [07
/Feb/2017
20:24:02]
"GET /hello/1 HTTP/1.1"
200 -
|
1
2
3
4
5
6
7
8
9
|
[root@web02 flask]
# cat id
from flask
import
Flask
app = Flask(__name__)
@app.route(
'/hello/<int:id>'
)
def hello(
id
):
return
'hello %d'
%
id
if
__name__==
'__main__'
:
app.run(host=
'0.0.0.0'
)
[root@web02 flask]
#
|
本文转自 小小三郎1 51CTO博客,原文链接:http://blog.51cto.com/wsxxsl/1895842,如需转载请自行联系原作者