-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (24 loc) · 874 Bytes
/
app.py
File metadata and controls
32 lines (24 loc) · 874 Bytes
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
from flask import Flask, jsonify
from predict_week import predict_week
from threading import Thread
from json import loads, dumps
import requests
app = Flask(__name__)
# app.config["DEBUG"] = True
@app.route('/', methods=['GET'])
def home():
return "<h1>RAIN</h1><p>This site is a prototype API for weather prediction.</p>"
@app.route('/predict/week', methods=['GET'])
def week():
def do_work():
json_obj = loads(dumps(predict_week()))
url = 'http://sofe3720.ml/predictions'
headers = {'content-type': 'application/json'}
# print(dumps(json_obj))
resp = requests.post(url, data=dumps(json_obj), headers=headers)
print(resp.text)
thread = Thread(target=do_work)
thread.start()
# return flask.jsonify({'data': predict_week()})
return jsonify({'status': 200, 'message': 'We out here!'})
app.run()