-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathServer.py
63 lines (48 loc) · 1.68 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
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
'''
Created on Feb 27, 2016
@author: Shaq
'''
from flask import Flask, jsonify, request, send_from_directory
from flask_restful import Resource, Api, reqparse, marshal_with, fields
from Uber_cost import Uber_database
from Estimate import Estimates
from Cost_function import return_best_locations_to_live
from GoogleDirections import GoogleDirections
from flask.ext.cors import CORS
#import request
app = Flask(__name__, static_url_path='')
api = Api(app)
CORS(app)
Uber_database=Uber_database()
class UberInfo(Resource):
def get(self):
"""
final version will output a list of places in JSON format that would be good to live
"""
parser = reqparse.RequestParser()
parser.add_argument('lat')
parser.add_argument('long')
parser.add_argument('money')
args = parser.parse_args()
print args['lat']
print args['long']
fake_lat=float(args['lat'])+1.0
fake_long=float(args['long'])+1.0
money=args['money']
locations=return_best_locations_to_live(args['lat'], args['long'], args['money'])
return locations
def post(self):
content = request.get_json(force=True)
gd = GoogleDirections()
destLatLng = gd.geoCodeAddress(gd.establishClient(), content["address"])
filteredHousingLocations=return_best_locations_to_live(destLatLng["lat"], destLatLng["lng"], content["money"])
return jsonify(filteredHousingLocations)
"""
@app.route('/')
def root():
return "Hello"
return send_from_directory('index.html', 'www')
"""
api.add_resource(UberInfo, '/')
if __name__ == '__main__':
app.run(debug=True)