Ayush19112 commited on
Commit
2424a84
1 Parent(s): 5c2bcd8

create app

Browse files
Files changed (1) hide show
  1. app +35 -0
app ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ import util
3
+
4
+ app = Flask(__name__)
5
+
6
+ @app.route('/get_location_names', methods=['GET'])
7
+ def get_location_names():
8
+ locations = util.get_location_names()
9
+ print(f"Locations fetched: {locations}")
10
+ response = jsonify({
11
+ 'locations': locations
12
+ })
13
+ response.headers.add('Access-Control-Allow-Origin', '*')
14
+ return response
15
+
16
+ @app.route('/predict_home_price', methods=['POST'])
17
+ def predict_home_price():
18
+ total_sqft = float(request.form['total_sqft'])
19
+ location = request.form['location']
20
+ bhk = int(request.form['bhk'])
21
+ bath = int(request.form['bath'])
22
+
23
+ estimated_price = util.get_estimated_price(location, total_sqft, bhk, bath)
24
+ print(f"Estimated price calculated: {estimated_price}")
25
+
26
+ response = jsonify({
27
+ 'estimated_price': estimated_price
28
+ })
29
+ response.headers.add('Access-Control-Allow-Origin', '*')
30
+ return response
31
+
32
+ if __name__ == "__main__":
33
+ print("Starting...")
34
+ util.load_saved_artifacts()
35
+ app.run()