summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2015-10-02 13:06:31 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2015-10-02 13:06:31 -0400
commitd594f9e88961cd2dbf667ea264f4251f87f9cd2d (patch)
tree69cc8126ad72329e7e4ada20c3b3ea3d6b814926 /main.py
downloaddashboard-master.tar.gz
Initial commitHEADmaster
Diffstat (limited to 'main.py')
-rw-r--r--main.py22
1 files changed, 22 insertions, 0 deletions
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/<latitude>/<longitude>')
+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()