frog.py 585 B

123456789101112131415161718192021222324
  1. from flask import Flask
  2. from flask import request
  3. from flask import make_response
  4. from flask import redirect
  5. from flask import render_template
  6. from flask import url_for
  7. app=Flask(__name__)
  8. @app.route('/')
  9. def index():
  10. return render_template('index.html')
  11. @app.route('/post/')
  12. def posts():
  13. allposts=[{'id':1,'title':'title1'},{'id':2,'title':'title2'}]
  14. return render_template('posts.html',posts=allposts)
  15. @app.route('/post/<int:id>')
  16. def post(id):
  17. return render_template('post.html',id=id)
  18. @app.route('/article/')
  19. def article():
  20. return redirect(url_for('posts'))