pgiovanni

Untitled

Jun 1st, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. from flask import Flask
  2. from markupsafe import escape
  3. app = Flask(__name__)
  4.  
  5. @app.route('/user/<username>')
  6. def show_user_profile(username):
  7.     # show the user profile for that user
  8.     return 'User %s' % escape(username)
  9.  
  10. @app.route('/post/<int:post_id>')
  11. def show_post(post_id):
  12.     # show the post with the given id, the id is an integer
  13.     return 'Post %d' % post_id
  14.  
  15. @app.route('/path/<path:subpath>')
  16. def show_subpath(subpath):
  17.     # show the subpath after /path/
  18.     return 'Subpath %s' % escape(subpath)
Advertisement
Add Comment
Please, Sign In to add comment