Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add sample for using template

  • Loading branch information...
commit 22fa8bbbe90ad0a8b030238775aaec4214b167b7 1 parent f6d70e1
@jugyo authored
View
4 README.md
@@ -13,6 +13,8 @@ Run
dev_appserver.py .
+and open 'http://localhost:8080/hello'.
+
Deploy
------
@@ -23,5 +25,5 @@ You should fix application name of app.yaml before deploy.
TODO
------
-* sample for using template
+* sample for using DataStore
* sample for test
View
10 app.py
@@ -2,16 +2,18 @@
sys.path.append('lib')
from flask import Flask
+from flask import render_template
# if necessary
# from flask import redirect, url_for, session, request,\
-# render_template, abort, flash, get_flashed_messages, g, Response\
+# abort, flash, get_flashed_messages, g, Response\
app = Flask(__name__)
-@app.route('/')
-def hello():
- return "Hello World!"
+@app.route('/hello/')
+@app.route('/hello/<name>')
+def hello(name=None):
+ return render_template('hello.html', name=name)
if __name__ == '__main__':
from wsgiref.handlers import CGIHandler
View
6 static/screen.css
@@ -0,0 +1,6 @@
+body {
+ width: 600px;
+ margin: 60px auto;
+ text-align: center;
+ font-family: 'Lucida Grande', sans-serif;
+}
View
4 templates/hello.html
@@ -0,0 +1,4 @@
+{% extends "layout.html" %}
+{% block body %}
+ <div class="content">Hello {{ name }}!</div>
+{% endblock %}
View
11 templates/layout.html
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ <title>flask-gae-template</title>
+ <link rel=stylesheet type=text/css href="{{ url_for('static', filename='screen.css') }}">
+ </head>
+ <body>
+
+ {% block body %}{% endblock %}
+
+ </body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.