frog.py 750 B

12345678910111213141516171819202122232425262728
  1. from flask import Flask,request,make_response,redirect,render_template,url_for,abort,flash
  2. app=Flask(__name__)
  3. app.config['SECRET_KEY']='132456'
  4. @app.errorhandler(404)
  5. def page_not_found(e):
  6. return render_template('404.html'),404
  7. @app.errorhandler(500)
  8. def internal_server_error(e):
  9. return render_template('500.html'),500
  10. @app.route('/')
  11. def index():
  12. return render_template('index.html')
  13. @app.route('/index2')
  14. def index2():
  15. return render_template('index2.html',title='Index - Frog')
  16. @app.route('/post/')
  17. def posts():
  18. allposts=[{'id':1,'title':'title1'},{'id':2,'title':'title2'}]
  19. return render_template('posts.html',posts=allposts)
  20. @app.route('/post/<int:id>')
  21. def post(id):
  22. return render_template('post.html',id=id)