from flask import Flask, url_for, render_template
from markupsafe import escape

app = Flask(__name__)


@app.route("/")
def index():
    context = {
        "number": 1337
    }
    return render_template("index.jinja", context=context)


@app.route('/user/<username>')
def user_profile(username):
    # show the user profile for that user
    return f'User {escape(username)}'


@app.route('/user/by_uuid/<uuid:user_id>')
def user_id(user_id):
    # show the user profile for that user
    return f'Your mom has this id: {escape(user_id)}'


@app.route('/post/<int:post_id>')
def post_show(post_id):
    # show the post with the given id, the id is an integer
    return f'Post {post_id}'


@app.route('/path/<path:subpath>')
def subpath_show(subpath):
    # show the subpath after /path/
    return f'Subpath {escape(subpath)}'


with app.test_request_context():
    print("{:=^80}".format("URIs"))
    print(url_for('index'))
    print(url_for('user_profile', username="yo mama"))
    print(url_for('user_id', user_id="blabla"))
    print(url_for('post_show', post_id=1337))
    print(url_for('subpath_show', subpath="blablabla"))
    print(url_for('static', filename='style.css'))
    print("=" * 80)
