File tree Expand file tree Collapse file tree 4 files changed +12
-12
lines changed
src/10-async-web/acityscape_api Expand file tree Collapse file tree 4 files changed +12
-12
lines changed Original file line number Diff line number Diff line change 1
- import flask
1
+ import quart
2
2
from views import city_api
3
3
from views import home
4
4
from config import settings
5
5
import services .weather_service
6
6
import services .sun_service
7
7
import services .location_service
8
8
9
- app = flask . Flask (__name__ )
9
+ app = quart . Quart (__name__ )
10
10
is_debug = True
11
11
12
12
app .register_blueprint (home .blueprint )
Original file line number Diff line number Diff line change 1
1
# Web framework requirements
2
- flask
2
+ quart
3
3
4
4
# Calling services requirements
5
5
requests
Original file line number Diff line number Diff line change 1
- import flask
1
+ import quart
2
2
from services import weather_service , sun_service , location_service
3
3
4
- blueprint = flask .blueprints .Blueprint (__name__ , __name__ )
4
+ blueprint = quart .blueprints .Blueprint (__name__ , __name__ )
5
5
6
6
7
7
@blueprint .route ('/api/weather/<zip_code>/<country>' , methods = ['GET' ])
8
8
def weather (zip_code : str , country : str ):
9
9
weather_data = weather_service .get_current (zip_code , country )
10
10
if not weather_data :
11
- flask .abort (404 )
12
- return flask .jsonify (weather_data )
11
+ quart .abort (404 )
12
+ return quart .jsonify (weather_data )
13
13
14
14
15
15
@blueprint .route ('/api/sun/<zip_code>/<country>' , methods = ['GET' ])
16
16
def sun (zip_code : str , country : str ):
17
17
lat , long = location_service .get_lat_long (zip_code , country )
18
18
sun_data = sun_service .for_today (lat , long )
19
19
if not sun_data :
20
- flask .abort (404 )
21
- return flask .jsonify (sun_data )
20
+ quart .abort (404 )
21
+ return quart .jsonify (sun_data )
Original file line number Diff line number Diff line change 1
- import flask
1
+ import quart
2
2
3
- blueprint = flask .blueprints .Blueprint (__name__ , __name__ )
3
+ blueprint = quart .blueprints .Blueprint (__name__ , __name__ )
4
4
5
5
6
6
@blueprint .route ('/' )
@@ -12,4 +12,4 @@ def index():
12
12
13
13
@blueprint .errorhandler (404 )
14
14
def not_found (_ ):
15
- return flask .Response ("The page was not found." , status = 404 )
15
+ return quart .Response ("The page was not found." , status = 404 )
You can’t perform that action at this time.
0 commit comments