-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.py
34 lines (26 loc) · 876 Bytes
/
application.py
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
30
31
32
33
34
from flask import Flask, render_template, request, jsonify
from flask_cors import CORS, cross_origin
from query import queryWeather
import os
app = Flask(__name__)
CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
@app.after_request
def after_request(response):
response.headers.add('Access-Control-Allow-Origin', '*')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
return response
@app.route("/")
def index():
return render_template("index.html")
@app.route("/weather")
def weather():
if request.method == 'GET':
print(request.args.get("lat"))
lat = request.args.get("lat")
lon = request.args.get("lon")
data = queryWeather(lat, lon)
return data
if __name__ == "__main__":
app.run()