-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
30 lines (26 loc) · 850 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
import logging
import socket
from is452 import app
from flask import make_response
# Default route
@app.route("/", methods=['GET'])
def default_route():
response = make_response("Python Flask API endpoint. There's nothing here! 😃")
response.mimetype = "text/plain"
return response
# Logger
logger = logging.getLogger(__name__)
logger = logging.getLogger()
handler = logging.StreamHandler()
formatter = logging.Formatter(
"%(asctime)s %(name)-12s %(levelname)-8s %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
if __name__ == "__main__":
logging.info("Starting microservice app...")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("localhost", 0))
port = sock.getsockname()[1]
sock.close()
app.run(port=5000, debug=True)