Advertisement
naren_paste

flask_dynamicContent

Oct 30th, 2023
847
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | Source Code | 0 0
  1. from flask import Flask, render_template
  2.  
  3. app = Flask(__name__)
  4.  
  5. @app.route('/')
  6. def home():
  7.     return 'Welcome to the Flask App with Dynamic Content!'
  8.  
  9. @app.route('/user/<username>')
  10. def display_user(username):
  11.     return f'Hello, {username}!'
  12.  
  13. if __name__ == '__main__':
  14.     app.run(debug=True)
  15.  
  16. ##### index.html #####
  17. <!DOCTYPE html>
  18. <html lang="en">
  19. <head>
  20.     <meta charset="UTF-8">
  21.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  22.     <title>Dynamic Greeting</title>
  23. </head>
  24. <body>
  25.     <h1>Hello, {{ username }}!</h1>
  26. </body>
  27. </html>
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement