-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.py
30 lines (23 loc) · 832 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
from flask import Flask, request, jsonify
import util
app = Flask(__name__)
@app.route('/get_location_names', methods=['GET'])
def get_location_names():
response = jsonify({
'locations': util.get_location_names()
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
@app.route('/predict_home_price', methods=['GET', 'POST'])
def predict_home_price():
rooms = request.form['rooms']
location = request.form['suburb']
response = jsonify({
'estimated_price': util.get_estimated_price(rooms,location)
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
if __name__ == "__main__":
print("Starting Python Flask Server For Home Price Prediction...")
util.load_saved_artifacts()
app.run()