-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathindex.py
More file actions
30 lines (23 loc) · 905 Bytes
/
index.py
File metadata and controls
30 lines (23 loc) · 905 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, request, jsonify
import arrow
app = Flask(__name__)
@app.route("/", defaults={"path": ""}, methods=["GET", "POST", "PUT", "DELETE"])
@app.route("/<path:path>", methods=["GET", "POST", "PUT", "DELETE"])
def hello_world(path):
requestId = request.headers.get("x-fc-request-id", "")
print("FC Invoke Start RequestId: " + requestId)
response = jsonify(
{
"msg": "Hello, World!" + " at " + arrow.now().format("YYYY-MM-DD HH:mm:ss"),
"request": {
"query": str(request.query_string, "utf-8"),
"path": path,
"data": str(request.stream.read(), "utf-8"),
"clientIp": request.headers.get("x-forwarded-for"),
},
}
)
print("FC Invoke End RequestId: " + requestId)
return response
if __name__ == "__main__":
app.run(host="0.0.0.0", port=9000)