-
Notifications
You must be signed in to change notification settings - Fork 169
/
Copy pathapp.py
34 lines (26 loc) · 871 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!python3
#This is the application script for launching a Python Timezone List Flask Web App.
from flask import Flask, render_template, request
import pendulum
import pytz
app = Flask(__name__)
#Create the list to populate the pull-down menu
def create_list():
tz_list = []
for tz in pytz.all_timezones:
tz_list.append(tz)
return tz_list
@app.route('/', methods=['GET', 'POST'])
def index():
tz_list = create_list()
choice = ''
tz_time = ''
if request.method == 'POST' and 'tz_menu' in request.form:
choice = request.form.get('tz_menu')
tz_time = pendulum.now(choice).to_datetime_string()
return render_template('index.html',
tz_list=tz_list,
choice=choice,
tz_time=tz_time)
if __name__ == "__main__":
app.run()