Last active
August 15, 2017 04:18
-
-
Save kunpengku/dfc9381a5ea05e0ab8c84e753f1abd1e to your computer and use it in GitHub Desktop.
flask01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf8 | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/433") | |
def hello_433(): | |
return "hello ", 433 | |
if __name__ == "__main__": | |
app.debug = True | |
app.run(host='0.0.0.0') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf8 | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/433") | |
def hello_header(): | |
return "hello ", 433, {'a':1, 'b':2} | |
if __name__ == "__main__": | |
app.debug = True | |
app.run(host='0.0.0.0') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf8 | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "hello world" | |
@app.route("/user/<name>") | |
def hello_you(name=None): | |
return "hello {name}".format(name=name) | |
if __name__ == "__main__": | |
app.debug = True | |
app.run(host='0.0.0.0') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: from hello import app | |
In [2]: | |
In [2]: | |
In [2]: app.url_map | |
Out[2]: | |
Map([<Rule '/' (GET, HEAD, OPTIONS) -> hello>, | |
<Rule '/static/<filename>' (GET, HEAD, OPTIONS) -> static>, | |
<Rule '/user/<name>' (GET, HEAD, OPTIONS) -> hello_you>]) | |
In [3]: | |
# 查看 路由情况 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment