forked from turkupy/beginners-python-weather
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyapp.py
More file actions
executable file
·29 lines (22 loc) · 789 Bytes
/
Copy pathmyapp.py
File metadata and controls
executable file
·29 lines (22 loc) · 789 Bytes
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
from flask import Flask, render_template, request, redirect
from weather import get_weather
app = Flask(__name__)
@app.route("/")
def home():
return render_template('home.html')
@app.route("/", methods=["POST"])
def get_city():
if request.method == "POST":
city = request.form["text"]
weather = get_weather(city)
weatherinfo = None
if not weather:
weatherinfo = 'Could not retrieve info for given city. Check input.'
else:
weatherinfo = 'Current temperature for {} is {}. Feels like {}. {}'.format(city, weather[0], weather[1], weather[2])
return render_template('home.html', result = weatherinfo)
@app.route("/magda")
def magda():
return "Hello...?"
if __name__ == "__main__":
app.run(debug=True)