-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
46 lines (32 loc) · 955 Bytes
/
server.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
from flask import Flask,request,jsonify,render_template,json
import joblib
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
__model = None
def load_model():
loaded_model = joblib.load("ai.model")
return loaded_model
def predict(args):
result = __model.predict([args])
return result
@app.route('/')
def home():
return render_template('home.html')
@app.route('/predict', methods = ["GET"])
def query_example():
args = request.args
beds = args.get("beds")
baths = args.get("baths")
sqft = args.get("sqft")
yr_built = args.get("yr_built")
basement = args.get("basement")
txyear = args.get("txyear")
insurance = args.get("insurance")
list_args = [beds,baths,sqft,yr_built,basement,txyear,insurance]
return jsonify({"price" : predict(list_args)[0]})
if __name__ == "__main__":
__model = load_model()
print("Starting Server")
app.run()
print("Server Started...")