-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapi.py
70 lines (47 loc) · 2.23 KB
/
api.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
64
65
66
67
68
69
70
from flask import Flask
from flask_restful import Resource, Api
from flight_finder import FlightFinder
app = Flask(__name__)
api = Api(app)
@app.route('/flights/<from_>/<to_>/<start_>')
def find_flights_oneway(from_, to_, start_):
ff = FlightFinder(from_, to_, start_)
return ff.find_flights()
@app.route('/flights/<from_>/<to_>/<start_>/<end_>')
def find_flights(from_, to_, start_, end_):
ff = FlightFinder(from_, to_, start_, end_)
return ff.find_flights()
@app.route('/flights/<from_>/<to_>/<start_>/<end_>/<passengers_>')
def find_flights_passengers(from_, to_, start_, end_, passengers_):
ff = FlightFinder(from_, to_, start_, end_, passengers_)
return ff.find_flights()
@app.route('/flights/<from_>/<to_>/<start_>/<end_>/<stops_>')
def find_flights_stops(from_, to_, start_, end_, stops_):
ff = FlightFinder(from_, to_, start_, end_, None, stops_)
return ff.find_flights()
@app.route('/flights/<from_>/<to_>/<start_>/<end_>/<passengers_>/<stops_>')
def find_flights_passengers_stops(from_, to_, start_, end_, stops_):
ff = FlightFinder(from_, to_, start_, end_, passengers_, stops_)
return ff.find_flights()
@app.route('/cheapest/<from_>/<to_>/<start_>')
def find_cheapest_oneway(from_, to_, start_):
ff = FlightFinder(from_, to_, start_)
return ff.find_flight()
@app.route('/cheapest/<from_>/<to_>/<start_>/<end_>')
def find_cheapest(from_, to_, start_, end_):
ff = FlightFinder(from_, to_, start_, end_)
return ff.find_flight()
@app.route('/cheapest/<from_>/<to_>/<start_>/<end_>/<passengers_>')
def find_cheapest_passengers(from_, to_, start_, end_, passengers_):
ff = FlightFinder(from_, to_, start_, end_, passengers_)
return ff.find_flight()
@app.route('/cheapest/<from_>/<to_>/<start_>/<end_>/<stops_>')
def find_cheapest_stops(from_, to_, start_, end_, stops_):
ff = FlightFinder(from_, to_, start_, end_, None, stops_)
return ff.find_flight()
@app.route('/cheapest/<from_>/<to_>/<start_>/<end_>/<passengers_>/<stops_>')
def find_cheapest_passengers_stops(from_, to_, start_, end_, stops_):
ff = FlightFinder(from_, to_, start_, end_, passengers_, stops_)
return ff.find_flight()
if __name__ == '__main__':
app.run(debug=True)