File tree 3 files changed +33
-12
lines changed
3 files changed +33
-12
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "healthchecks" : {
3
+ "api" : [
4
+ {
5
+ "type" : " startup" ,
6
+ "name" : " api check" ,
7
+ "description" : " Checking if the app responds to the /health/ready endpoint" ,
8
+ "path" : " /healthz" ,
9
+ "attempts" : 3
10
+ }
11
+ ]
12
+ }
13
+ }
Original file line number Diff line number Diff line change 1
- from flask import Flask , g , request
2
- from sqlalchemy import select
1
+ from flask import Flask
3
2
4
- from . import db as dbm
5
3
from .config import Config
6
4
from .ext import db
7
5
from .v1_api import bp as v1_bp
@@ -13,14 +11,6 @@ def create_app():
13
11
14
12
db .init_app (app )
15
13
16
- @app .before_request
17
- def before_request ():
18
- if not hasattr (g , "tenant" ):
19
- hostname = request .host .split (":" )[0 ]
20
- g .tenant = db .session .scalars (
21
- select (dbm .Tenant ).filter_by (hostname = hostname ).limit (1 )
22
- ).first ()
23
-
24
14
@app .teardown_request
25
15
def teardown_request (exc ):
26
16
if exc :
@@ -29,4 +19,8 @@ def teardown_request(exc):
29
19
30
20
app .register_blueprint (v1_bp )
31
21
22
+ @app .route ("/healthz" )
23
+ def healthz ():
24
+ return {"status" : "ok" }
25
+
32
26
return app
Original file line number Diff line number Diff line change 1
- from flask import Blueprint
1
+ from flask import Blueprint , Flask , g , request
2
2
from flask_restful import Api
3
+ from sqlalchemy import select
3
4
5
+ from ..ext import db
6
+ from . import db as dbm
4
7
from .flights import FlightCollectionResource , FlightResource
5
8
6
9
bp = Blueprint ("api" , __name__ , url_prefix = "/api" )
10
+
11
+
12
+ @bp .before_request
13
+ def before_request ():
14
+ if not hasattr (g , "tenant" ):
15
+ hostname = request .host .split (":" )[0 ]
16
+ g .tenant = db .session .scalars (
17
+ select (dbm .Tenant ).filter_by (hostname = hostname ).limit (1 )
18
+ ).first ()
19
+
20
+
7
21
api = Api (bp )
8
22
9
23
api .add_resource (FlightCollectionResource , "/v1/flights" )
You can’t perform that action at this time.
0 commit comments