-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (23 loc) · 773 Bytes
/
app.py
File metadata and controls
30 lines (23 loc) · 773 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
from flask import Flask, jsonify, request
import os
import uuid
from datetime import datetime
import logging
app = Flask(__name__)
logging.basicConfig(filename='/var/log/app/access.log', level=logging.INFO, format='%(asctime)s %(message)s')
@app.route("/")
def random_guid():
guid = str(uuid.uuid4())
logging.info(f"guid: {guid}, ip: {request.remote_addr}")
pod_name = os.getenv("HOSTNAME", "unknown-pod")
node_name = os.getenv("NODE_NAME", "unknown-node")
current_time = datetime.now().isoformat()
response = {
"current_time": current_time,
"guid": guid,
"pod_name": pod_name,
"node_name": node_name
}
return jsonify(response)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)