weather final

parent f8266cee
This source diff could not be displayed because it is too large. You can view the blob instead.
import json, time
from flask import Flask, jsonify, request
from flask_cors import CORS
import pickle
app = Flask(__name__)
CORS(app, resources={r"/weather/*": {"origins": "*"}})
@app.route('/', methods=['GET'])
def home_page():
data_set = {'page': 'Home', 'Message': 'successfully load the Home page', 'Timestamp': time.time()}
json_dump = json.dumps(data_set)
return json_dump
@app.route('/weather/', methods=['GET'])
def request_page():
loaded_gbr = pickle.load(open("model.dat", "rb"))
data = str(loaded_gbr.predict([[float(request.args.get('time')),float(request.args.get('lat')),float(request.args.get('lang')),int(request.args.get('temp')),int(request.args.get('hum'))]])[0])
json_dump = json.dumps({"data":data})
return json_dump
if __name__ == '__main__':
app.run(host="127.0.0.1", port=7777)
#using this type
# http://127.0.0.1:7777/weather/?time=12.00&lat=6.928589&lang=79.899354&temp=36&hum=60
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
BTIME(h) DATE LOCATION LONGITUDE LATITUDE TEMPERATURE(c) HUMIDITY SUMMARY
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment