-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
40 lines (33 loc) · 1.1 KB
/
app.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
'''
flask --app app run --debug
'''
from flask import Flask, jsonify, abort
from Controller.SpaceX import SpaceX
app = Flask(__name__)
@app.route("/")
def hello_world():
abort(404)
@app.route("/api/homepage-tiles")
def HomepageTiles():
spacex = SpaceX("homepage-tiles")
data = spacex.homepage_tiles()
if data and spacex.data_fetcher.last_status_code == 200:
return jsonify(data)
else:
return jsonify(data), spacex.data_fetcher.last_status_code
@app.route("/api/launches-page-tiles")
def LaunchesPageTiles():
spacex = SpaceX("launches-page-tiles")
data = spacex.launches_page_tiles()
if data and spacex.data_fetcher.last_status_code == 200:
return jsonify(data)
else:
return jsonify(data), spacex.data_fetcher.last_status_code
@app.route("/api/launches-page-stats")
def LaunchesPageStats():
spacex = SpaceX("launches-page-stats")
data = spacex.launches_page_stats()
if data and spacex.data_fetcher.last_status_code == 200:
return jsonify(data)
else:
return jsonify(data), spacex.data_fetcher.last_status_code