123456789101112131415161718192021222324 |
- from flask import Flask
- from flask import request
- from flask import make_response
- from flask import redirect
- from flask import render_template
- from flask import url_for
- app=Flask(__name__)
- @app.route('/')
- def index():
- return render_template('index.html')
- @app.route('/post/')
- def posts():
- allposts=[{'id':1,'title':'title1'},{'id':2,'title':'title2'}]
- return render_template('posts.html',posts=allposts)
- @app.route('/post/<int:id>')
- def post(id):
- return render_template('post.html',id=id)
- @app.route('/article/')
- def article():
- return redirect(url_for('posts'))
|