Guest User

Untitled

a guest
Jul 15th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. from flask import Flask, request, render_template
  2. app = Flask(__name__)
  3.  
  4. @app.route('/')
  5. def index():
  6. return 'Index Page'
  7.  
  8. @app.route('/hello')
  9. def hello():
  10. return "Hello World!"
  11.  
  12. @app.route('/user/<username>')
  13. def show_user_profile(username):
  14. return "user: " + username
  15.  
  16. @app.route('/post/<int:post_id>')
  17. def show_post(post_id):
  18. return "post_id: " + str(post_id)
  19.  
  20. @app.route('/login', methods=['GET', 'POST'])
  21. def login():
  22. if request.method == 'POST':
  23. app.logger.info(request.form['name'] + ' is login')
  24. return render_template('login.html', name=request.form['name'])
  25. else:
  26. return render_template('login.html')
  27.  
  28. if __name__ == '__main__':
  29. app.run(debug = True)
Add Comment
Please, Sign In to add comment