Skip to content

Commit a9e7d62

Browse files
committed
samples
1 parent 3c5f278 commit a9e7d62

27 files changed

+10213
-3
lines changed

flask/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'''
2+
How to run:
3+
$ export FLASK_APP=hello_world.py
4+
$ export FLASK_ENV=development
5+
$ flask.run
6+
'''

flask/sample/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Bootstrap Template
2+
# https://getbootstrap.com/docs/3.3/getting-started/
3+
4+
'''
5+
How to run:
6+
$ export FLASK_APP=XX.py
7+
$ export FLASK_ENV=development
8+
$ flask.run
9+
'''

flask/sample/sample_index.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import numpy
2+
from flask import Flask,render_template,request,redirect,url_for
3+
4+
app = Flask(__name__)
5+
6+
def pick_up():
7+
messages = [ "hello!",
8+
"Good Moreing",
9+
"Good Night!"
10+
]
11+
return numpy.random.choice(messages)
12+
13+
@app.route("/")
14+
def index():
15+
title = "this is test title!"
16+
messages = pick_up()
17+
return render_template('index.html',messages=messages, title=title)
18+
19+
20+
@app.route("/post",methods = ['GET' , 'POST'])
21+
def post():
22+
title = "there is a post"
23+
if request.method == 'POST':
24+
name = request.form['name']
25+
return render_template('index.html',name=name, title=title)
26+
else:
27+
return redirect(url_for('index'))
28+
29+
30+
if __name__ == "__main__":
31+
app.debug = True
32+
app.run(host = '0.0.0.0') # can access from anywhere

0 commit comments

Comments
 (0)