首页 > 代码库 > 01-flask

01-flask

  1. http://59.110.26.9:5000/



技术分享

[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 -


[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.


技术分享

技术分享



[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 -


[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.

技术分享

[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 -
[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]#


本文出自 “砖家博客” 博客,请务必保留此出处http://wsxxsl.blog.51cto.com/9085838/1895842

01-flask