From 9c5353c67ab03442b37da103b7f3e7a66dbdd7ae Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Fri, 7 Feb 2025 14:44:04 +0100 Subject: [PATCH] feat: more routs with url params --- flaskex/app.py | 28 +++++++++++++++++++++++++++- run.sh | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/flaskex/app.py b/flaskex/app.py index 05b6239..2226173 100644 --- a/flaskex/app.py +++ b/flaskex/app.py @@ -1,7 +1,33 @@ from flask import Flask +from markupsafe import escape app = Flask(__name__) @app.route("/") def hello_world(): - return "

Hello, World!

" + return r""" + +

Hello, World!

+ blabla + blabla id + """ + +@app.route('/user/') +def show_user_profile(username): + # show the user profile for that user + return f'User {escape(username)}' + +@app.route('/user/by_uuid/') +def show_user_id(user_id): + # show the user profile for that user + return f'Your mom has this id: {escape(user_id)}' + +@app.route('/post/') +def show_post(post_id): + # show the post with the given id, the id is an integer + return f'Post {post_id}' + +@app.route('/path/') +def show_subpath(subpath): + # show the subpath after /path/ + return f'Subpath {escape(subpath)}' diff --git a/run.sh b/run.sh index 657c166..e933417 100755 --- a/run.sh +++ b/run.sh @@ -1,2 +1,2 @@ #!/bin/bash -flask --app flaskex/app run +flask --app flaskex/app run --debug