from flask import Flask
if __name__ == '__main__':
app = Flask(__name__)
@app.route('/fxxk') # if the url ends with /fxxk. the default method is 'GET'
def hello_world():
return 'Hello World'
@app.route('/123/<what>', methods=['GET', 'POST']) # if the url ends with /123/<var>, but var != ''
def do_something(what):
return 'what= {}'.format(what)
@app.route('/get_number/<int:tel>')
def do_number(tel): # tel is recognized as int.
return 'tel= {}'.format(tel)
@app.route('/')
def do_index():
return 'index'
app.run(host='127.0.0.1', port=80, debug=True) # 80 is the default port of the browser.