-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
31 lines (22 loc) · 786 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
from flask import Flask
from flask import render_template
from flask import request
import getWeather
#creating flask web app class
app = Flask(__name__)
#listen for routes
#listen for index route
@app.route('/')
def index_page():
return render_template('index.html')
#listen for forecast route
@app.route('/forecast', methods=['GET'])
def forecast_page():
#get city name from html form request
city = str(request.args['city_input'])
weatherData = getWeather.getWeather(city)
#if city is real
if weatherData != False:
return render_template('forecast.html', temperature=weatherData['temperature'], icon=weatherData['icon'], summary=weatherData['summary'], city=city.title())
#if city is not real
return render_template('index.html')