File tree Expand file tree Collapse file tree 4 files changed +75
-0
lines changed
appengine/standard_python37/warmup Expand file tree Collapse file tree 4 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ runtime : python37
2+
3+ inbound_services :
4+ - warmup
Original file line number Diff line number Diff line change 1+ # Copyright 2018 Google LLC.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ # [START gae_python37_warmup_app]
16+ from flask import Flask
17+
18+
19+ app = Flask (__name__ )
20+
21+
22+ @app .route ('/' )
23+ def main ():
24+ return 'Hello World!'
25+
26+
27+ @app .route ('/_ah/warmup' )
28+ def warmup ():
29+ # Handle your warmup logic here, e.g. set up a database connection pool
30+ return '' , 200 , {}
31+
32+
33+ if __name__ == '__main__' :
34+ # This is used when running locally only. When deploying to Google App
35+ # Engine, a webserver process such as Gunicorn will serve the app. This
36+ # can be configured by adding an `entrypoint` to app.yaml.
37+ app .run (host = '127.0.0.1' , port = 8080 , debug = True )
38+ # [END gae_python37_warmup_app]
Original file line number Diff line number Diff line change 1+ # Copyright 2018 Google Inc. All Rights Reserved.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ import main
16+
17+
18+ def test_index ():
19+ main .app .testing = True
20+ client = main .app .test_client ()
21+
22+ r = client .get ('/' )
23+ assert r .status_code == 200
24+ assert 'Hello World' in r .data .decode ('utf-8' )
25+
26+
27+ def test_warmup ():
28+ main .app .testing = True
29+ client = main .app .test_client ()
30+
31+ r = client .get ('/' )
32+ assert r .status_code == 200
Original file line number Diff line number Diff line change 1+ flask == 1.0.2
You can’t perform that action at this time.
0 commit comments