Browse Source

Chapter 3: Templates (3a)

master
T. Meissner 6 years ago
parent
commit
02a1b3404e
3 changed files with 6 additions and 3 deletions
  1. +4
    -3
      hello.py
  2. +1
    -0
      templates/index.html
  3. +1
    -0
      templates/user.html

+ 4
- 3
hello.py View File

@ -1,12 +1,13 @@
from flask import Flask
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return '<h1>Hello World!</h1>'
return render_template('index.html')
@app.route('/user/<name>')
def user(name):
return '<h1>Hello, {}!</h1>'.format(name)
return render_template('user.html', name=name)

+ 1
- 0
templates/index.html View File

@ -0,0 +1 @@
<h1>Hello World!</h1>

+ 1
- 0
templates/user.html View File

@ -0,0 +1 @@
<h1>Hello, {{ name }}!</h1>

Loading…
Cancel
Save