-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathapp.py
48 lines (31 loc) · 947 Bytes
/
app.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import logging
import os
import time
from flask import Flask, request
APP_PORT = os.getenv("APP_PORT", "3003")
app = Flask(__name__)
@app.route("/payments/charge", methods=["POST"])
def charge():
logging.info(f"Charging payment for order: {request.json}")
# Simulate work
time.sleep(1)
return '', 200
@app.route("/payments/refund", methods=["POST"])
def refund():
logging.info(f"Refunding payment for order: {request.json}")
# Simulate work
time.sleep(1)
return '', 200
@app.route("/", methods=["GET"])
@app.route("/healthz", methods=["GET"])
def hello():
return f"Hello from {__name__}", 200
def main():
# Start the Flask app server
app.run(port=APP_PORT, debug=True, use_reloader=False)
if __name__ == "__main__":
logging.basicConfig(
format='%(asctime)s.%(msecs)03d %(levelname)s: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
level=logging.INFO)
main()