Flask
Start Up
from flask import Flask app = Flask(__name__) @app.route('/') def index(): return '<h1>Hello world</h1>' @app.route('/user/<name>') def user(name): return '<h1>Hello{}</h1>'.format(name) app.add_url_rule('/', 'index', index)
export FLASK_APP=main.py
export FLASK_DEBUG=1
HTTP Methods
with app.test_request_context(): print(url_for('index')) print(url_for('login')) print(url_for('login', next='/')) print(url_for('profile', username='John Doe'))