Permalink
Browse files

add @app.route('/')

  • Loading branch information...
1 parent 9299a82 commit d9be1c35ee2e4b9ae172d575d3f6b51379cec807 @jugyo committed Aug 5, 2010
Showing with 16 additions and 6 deletions.
  1. +9 −6 app.py
  2. +7 −0 templates/index.html
View
15 app.py
@@ -2,18 +2,21 @@
sys.path.append('lib')
from flask import Flask
-from flask import render_template
+from flask import render_template, request
# if necessary
-# from flask import redirect, url_for, session, request,\
+# from flask import redirect, url_for, session,\
# abort, flash, get_flashed_messages, g, Response\
app = Flask(__name__)
-@app.route('/hello/')
-@app.route('/hello/<name>')
-def hello(name=None):
- return render_template('hello.html', name=name)
+@app.route('/')
+def index():
+ return render_template('index.html')
+
+@app.route('/hello')
+def hello():
+ return render_template('hello.html', name=request.args.get('name'))
if __name__ == '__main__':
from wsgiref.handlers import CGIHandler
View
@@ -0,0 +1,7 @@
+{% extends "layout.html" %}
+{% block body %}
+ <form action="{{ url_for('hello') }}" method="get">
+ <input type="text" name="name" />
+ <input type="submit" value="hello"/>
+ </form>
+{% endblock %}

0 comments on commit d9be1c3

Please sign in to comment.