-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoo.py
More file actions
32 lines (24 loc) · 761 Bytes
/
Copy pathfoo.py
File metadata and controls
32 lines (24 loc) · 761 Bytes
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
import logging
import os
import requests
import google.cloud.logging
from flask import Flask
from flask import make_response
from waitress import serve
app = Flask(__name__)
client = google.cloud.logging.Client()
client.setup_logging()
@app.route("/foo", methods=["POST"])
def foo():
try:
r = requests.post("http://localhost:5000/sidecar", json={})
except:
logging.error("foo is available but sidecar isn't")
return make_response("bar", 400)
logging.info("both foo and sidecar are available")
return make_response("foo", 200)
@app.route("/", methods=["GET"])
def health_check():
return make_response("ok", 200)
if __name__ == "__main__":
serve(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))