summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
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()