-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
33 lines (27 loc) · 1.04 KB
/
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
from flask import Flask, request, jsonify
import util
app = Flask(__name__)
@app.route('/get_location_names')
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=['POST'])
def predict_home_price():
print("Received POST request at /predict_home_price")
total_sqft = float(request.form['total_sqft'])
location = request.form['location']
bhk = int(request.form['bhk'])
bath = int(request.form['bath'])
response = jsonify({
'estimated_price': util.get_estimated_price(location, total_sqft, bhk, bath)
})
response.headers.add('Access-Control-Allow-Origin', '*')
return response
if __name__ == "__main__":
print("Starting python flask server for home price prediction on Bangalore city")
util.load_saved_artefacts() # Ensure artefacts are loaded before the server starts
#app.run()
app.run()