BrickTracker/app.py

39 lines
864 B
Python
Raw Normal View History

2025-01-17 11:03:00 +01:00
# This need to be first
import eventlet
2025-01-17 11:03:00 +01:00
eventlet.monkey_patch()
2024-12-30 09:28:15 +01:00
2025-01-17 11:03:00 +01:00
import logging # noqa: E402
2024-06-29 17:32:47 +02:00
2025-01-17 11:03:00 +01:00
from flask import Flask # noqa: E402
2024-04-16 21:36:34 +02:00
2025-01-17 11:03:00 +01:00
from bricktracker.app import setup_app # noqa: E402
from bricktracker.socket import BrickSocket # noqa: E402
2024-02-28 20:08:16 +01:00
2025-01-17 11:03:00 +01:00
logger = logging.getLogger(__name__)
2024-12-28 13:58:01 +01:00
2024-12-28 09:34:07 +01:00
2025-01-17 11:03:00 +01:00
if __name__ == '__main__':
# Create the Flask app
app = Flask(__name__)
2024-12-30 09:28:15 +01:00
2025-01-17 11:03:00 +01:00
# Setup the app
setup_app(app)
2024-12-30 09:28:15 +01:00
2025-01-17 11:03:00 +01:00
# Create the socket
s = BrickSocket(
app,
threaded=not app.config['NO_THREADED_SOCKET'].value,
2024-12-30 09:28:15 +01:00
)
2025-01-17 11:03:00 +01:00
# Run the application
logger.info('Starting BrickTracker on {host}:{port}'.format(
host=app.config['HOST'].value,
port=app.config['PORT'].value,
))
s.socket.run(
app,
host=app.config['HOST'].value,
debug=app.config['DEBUG'].value,
port=app.config['PORT'].value,
2024-12-30 09:28:15 +01:00
)