summaryrefslogtreecommitdiffstats
path: root/main.py
blob: caf477ad3b7df176b10271f8e362269040893ed9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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()