Skip to content

Instantly share code, notes, and snippets.

@kunpengku
Last active August 15, 2017 04:18
Show Gist options
  • Save kunpengku/dfc9381a5ea05e0ab8c84e753f1abd1e to your computer and use it in GitHub Desktop.
Save kunpengku/dfc9381a5ea05e0ab8c84e753f1abd1e to your computer and use it in GitHub Desktop.
flask01
#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')
#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')
#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')
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