From d594f9e88961cd2dbf667ea264f4251f87f9cd2d Mon Sep 17 00:00:00 2001 From: Thibaut Horel Date: Fri, 2 Oct 2015 13:06:31 -0400 Subject: Initial commit --- main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 main.py (limited to 'main.py') diff --git a/main.py b/main.py new file mode 100644 index 0000000..caf477a --- /dev/null +++ b/main.py @@ -0,0 +1,22 @@ +from flask import Flask, render_template +import requests +app = Flask(__name__) + +app.config.from_pyfile("config.cfg") +api_key = app.config["API_KEY"] +api_root = "https://api.forecast.io/forecast/" + + +@app.route('/weather//') +def weather(latitude, longitude): + url = api_root + api_key + "/" + latitude + "," + longitude + r = requests.get(url, params={"exclude": "alerts", "units": "ca"}) + return r.text + + +@app.route('/') +def main(): + return render_template("index.html") + +if __name__ == '__main__': + app.run() -- cgit v1.2.3-70-g09d2