aboutsummaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'app.py')
-rw-r--r--app.py31
1 files changed, 0 insertions, 31 deletions
diff --git a/app.py b/app.py
deleted file mode 100644
index 72e74ca..0000000
--- a/app.py
+++ /dev/null
@@ -1,31 +0,0 @@
1#!/usr/bin/env python3
2import json, requests, datetime, argparse, pytz, flask
3import library, forms
4
5app = flask.Flask(__name__)
6app.config['SECRET_KEY'] = "hunter2"
7
8@app.route('/', methods=('GET','POST'))
9def index():
10 form = forms.WeatherForm()
11 if form.validate_on_submit():
12 location = form.location.data
13 return flask.redirect(flask.url_for('weather', location=location))
14 return flask.render_template("index.html", form=form)
15
16
17@app.route('/weather', methods=('GET','POST'))
18def weather():
19 location = flask.request.args.get('location', type=str)
20 latitude, longitude = library.get_lat_long(location)
21 data = library.get_data(latitude, longitude)
22 hour = library.get_current_rounded_time(data["timezone"]).hour
23 form = forms.WeatherForm()
24 if form.validate_on_submit():
25 location = form.location.data
26 return flask.redirect(flask.url_for('weather', location=location))
27 return flask.render_template("weather.html", data=data, form=form, weather_codes=library.weather_codes,
28 weather_icons=library.weather_icons, hour=hour)
29
30if __name__ == "__main__":
31 app.run()