|
@@ -3,28 +3,22 @@ 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('/filter')
|
|
|
-def test_filter():
|
|
|
- return render_template('filter.html',words='<h1>hello filter!</h1>')
|
|
|
+@app.route('/post/')
|
|
|
+def posts():
|
|
|
+ allposts=[{'id':1,'title':'title1'},{'id':2,'title':'title2'}]
|
|
|
+ return render_template('posts.html',posts=allposts)
|
|
|
|
|
|
-@app.route('/age/<int:myage>')
|
|
|
-def age(myage):
|
|
|
- return render_template('age.html',myage=myage)
|
|
|
+@app.route('/post/<int:id>')
|
|
|
+def post(id):
|
|
|
+ return render_template('post.html',id=id)
|
|
|
|
|
|
-@app.route('/for')
|
|
|
-def for_return():
|
|
|
- fruits=['apple','orange','watermelon']
|
|
|
- profile1={'id':1,'name':'Felix','sex':'male','height':'178cm','weight':'74kg'}
|
|
|
- profile2={'id':2,'name':'Lily','sex':'female','height':'169cm','weight':'50kg'}
|
|
|
- profiles=[profile1,profile2]
|
|
|
- return render_template('for.html',fruits=fruits,profiles=profiles)
|
|
|
-
|
|
|
-@app.route('/tags')
|
|
|
-def tags():
|
|
|
- return render_template('tags.html')
|
|
|
+@app.route('/article/')
|
|
|
+def article():
|
|
|
+ return redirect(url_for('posts'))
|