Quantcast
Channel: 一言多いプログラマーの独り言
Viewing all articles
Browse latest Browse all 846

Python+Flaskで、テンプレート

$
0
0
Python+Flaskで、テンプレートです。テンプレートが表示できました。ちょっと感動(笑)。


from flask import Flask, render_template
app = Flask(__name__)

@app.route('/hello/')
@app.route('/hello/<name>')
def hello(name=None):
return render_template('hello.html', name=name)

<!doctype html>
<title>Hello from Flask</title>
{% if name %}
<h1>Hello {{ name }}!</h1>
{% else %}
<h1>Hello, World!</h1>
{% endif %}

実際に設定してみたのがこちら

参考サイト
Quickstart(Flask Documentation)

Viewing all articles
Browse latest Browse all 846

Trending Articles