-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
63 lines (54 loc) · 1.8 KB
/
app.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pandas as pd
import numpy as np
import pickle
from flask import Flask, jsonify, request ,render_template
# from flask_cors import CORS, cross_origin
#import libraries
#Initialize the flask App
app = Flask(__name__)
# CORS(app)
maxT = pickle.load(open('forecast_model_maxT.pkl', 'rb'))
minT = pickle.load(open('forecast_model_minT.pkl', 'rb'))
print("working")
#default page of our web-app
@app.route('/')
def home():
print("working good")
return "<h1>HIIIII</h1>"
@app.route('/predict',methods=['GET'])
def home1():
maxT = pickle.load(open('forecast_model_maxT.pkl', 'rb'))
minT = pickle.load(open('forecast_model_minT.pkl', 'rb'))
d={}
d['Query'] = str(request.args['Query'])
print("working good")
future_max = maxT.make_future_dataframe(periods=365)
forecast = maxT.predict(future_max)
df1 = pd.DataFrame(forecast)
df2 = df1[['ds','yhat']]
df2['ds'] = df2['ds'].astype(str)
future_min = minT.make_future_dataframe(periods=365)
forecast_m = minT.predict(future_min)
df1_m = pd.DataFrame(forecast_m)
df2_m = df1_m[['ds','yhat']]
df2_m['ds'] = df2_m['ds'].astype(str)
for i in range(len(df2)):
if(d['Query'] == df2['ds'][i]):
print("Min Temperature : " + str(df2_m['yhat'][i]))
print("Max Temperature : " + str(df2['yhat'][i]))
dict={}
dict['Max_temp']=str(df2['yhat'][i])
dict['Min_temp']=str(df2_m['yhat'][i])
return jsonify(dict)
# return render_template('index.html',prediction_text='Hello')
@app.route('/hi')
def home12():
print("working good")
return "HIIII"
@app.route('/trial',methods=['GET'])
def trial():
d={}
d['Query'] = str(request.args['Query'])
return jsonify(d)
if __name__ == "__main__":
app.run()