diff --git a/flaskex/app.py b/flaskex/app.py index 2226173..e3340cf 100644 --- a/flaskex/app.py +++ b/flaskex/app.py @@ -1,33 +1,48 @@ -from flask import Flask +from flask import Flask, url_for from markupsafe import escape app = Flask(__name__) @app.route("/") -def hello_world(): - return r""" - +def index(): + return f""" + + Deine Mama + + +

Hello, World!

blabla blabla id + """ @app.route('/user/') -def show_user_profile(username): +def 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): +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/') -def show_post(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/') -def show_subpath(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) diff --git a/flaskex/bla.py b/flaskex/bla.py new file mode 100644 index 0000000..d2a009a --- /dev/null +++ b/flaskex/bla.py @@ -0,0 +1,5 @@ +class Bla: + def foo(self): + self.do() + self.the() + self.thing() diff --git a/flaskex/static/style.css b/flaskex/static/style.css new file mode 100644 index 0000000..ea8200b --- /dev/null +++ b/flaskex/static/style.css @@ -0,0 +1,3 @@ +body { + background: tomato; +}