Skip to content

Commit afd2535

Browse files
authored
fixit: clean up appengine/standard_python3/warmup (GoogleCloudPlatform#10072)
* fixit: clean up appengine/standard_python3/warmup * fixit: remove stray whitespace
1 parent 606dfb2 commit afd2535

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

appengine/standard_python3/warmup/main.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,32 @@
2020
app = Flask(__name__)
2121

2222

23-
@app.route('/')
23+
@app.route("/")
2424
def main():
25-
return 'Hello World!'
25+
"""Serves a predefined placeholder string.
2626
27+
Returns:
28+
A predefined string saying 'Hello World!'
29+
"""
30+
return "Hello World!"
2731

28-
@app.route('/_ah/warmup')
32+
33+
@app.route("/_ah/warmup")
2934
def warmup():
30-
# Handle your warmup logic here, e.g. set up a database connection pool
31-
return '', 200, {}
35+
"""Served stub function returning no content.
36+
37+
Your warmup logic can be implemented here (e.g. set up a database connection pool)
38+
39+
Returns:
40+
An empty string, an HTTP code 200, and an empty object.
41+
"""
42+
return "", 200, {}
3243

3344

34-
if __name__ == '__main__':
45+
if __name__ == "__main__":
3546
# This is used when running locally only. When deploying to Google App
3647
# Engine, a webserver process such as Gunicorn will serve the app. This
3748
# can be configured by adding an `entrypoint` to app.yaml.
38-
app.run(host='127.0.0.1', port=8080, debug=True)
49+
app.run(host="127.0.0.1", port=8080, debug=True)
3950
# [END gae_python3_warmup_app]
4051
# [END gae_python38_warmup_app]

appengine/standard_python3/warmup/main_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ def test_index():
1919
main.app.testing = True
2020
client = main.app.test_client()
2121

22-
r = client.get('/')
22+
r = client.get("/")
2323
assert r.status_code == 200
24-
assert 'Hello World' in r.data.decode('utf-8')
24+
assert "Hello World" in r.data.decode("utf-8")
2525

2626

2727
def test_warmup():
2828
main.app.testing = True
2929
client = main.app.test_client()
3030

31-
r = client.get('/_ah/warmup')
31+
r = client.get("/_ah/warmup")
3232
assert r.status_code == 200

0 commit comments

Comments
 (0)