forked from greyli/helloflask
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FLASK_ENV=development |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
import click | ||
from flask import Flask | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
# the minimal Flask application | ||
@app.route('/') | ||
def index(): | ||
return '<h1>Hello, World!</h1>' | ||
|
||
|
||
# bind multiple URL for one view function | ||
@app.route('/hi') | ||
@app.route('/hello') | ||
def say_hello(): | ||
return '<h1>Hello, Flask!</h1>' | ||
|
||
|
||
# dynamic route, URL variable default | ||
@app.route('/greet', defaults={'name': 'Programmer'}) | ||
@app.route('/greet/<name>') | ||
def greet(name): | ||
return '<h1>Hello, %s!</h1>' % name | ||
|
||
|
||
# custom flask cli command | ||
@app.cli.command() | ||
def hello(): | ||
"""Just say hello.""" | ||
click.echo('Hello, Human!') |