-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather_app.py
35 lines (29 loc) · 1020 Bytes
/
weather_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
35
from flask import Flask, render_template, request, redirect, url_for
from weather import Weather, WeatherException
app = Flask(__name__)
app.config.from_pyfile('config/config.cfg')
w = Weather(app.config)
@app.route('/')
def homepage():
return render_template('homepage.html')
@app.route('/result', methods=['POST', 'GET'])
def result_page():
if request.method == 'POST':
location = request.form
w.set_location(location.get('location'))
try:
return render_template('result.html', data=w.get_forecast_data())
except WeatherException:
app.log_exception(WeatherException)
return render_template('error.html')
else:
return redirect(url_for('homepage'))
@app.route('/about', methods=['GET'])
def about_page():
return render_template('about.html')
if __name__ == '__main__':
#<<<<<<< HEAD
app.run(host='0.0.0.0', port=8080)
#=======
# app.run(host='0.0.0.0', port=80)
#>>>>>>> 947b935549ca986524074f1c56ee16103ba4edaf