support-formatter-api/support_formatter/server.py
Firq 1eafc1a0e1
All checks were successful
/ backend-pylint (push) Successful in 1m5s
/ build-artifacts (push) Successful in 13s
/ publish-artifacts (push) Successful in 43s
/ release (push) Successful in 2m54s
/ build-and-push-container (push) Successful in 2m10s
Switched API
2024-10-04 00:31:31 +02:00

31 lines
1,008 B
Python

# pylint: disable=multiple-statements,wrong-import-position,wrong-import-order
from gevent.monkey import patch_all; patch_all()
from gevent.pywsgi import WSGIServer
from .app import Application
from .routes import interface_routes, formatter_routes, redirect_routes
from .config import APISettings, ServerSettings
APISettings.FILE_SAVE_DIRECTORY.mkdir(parents=True, exist_ok=True)
APP = Application.get_instance()
app, api = APP.app, APP.api
api.register_blueprint(redirect_routes)
api.register_blueprint(interface_routes)
api.register_blueprint(formatter_routes)
HOSTNAME, PORT = ServerSettings.HOSTNAME, ServerSettings.PORT
def run_server():
http_Server = WSGIServer((HOSTNAME, PORT), app)
try:
print(f"Server available on http://{HOSTNAME}:{PORT}/")
print(f"View docs on http://{HOSTNAME}:{PORT}/swagger")
http_Server.serve_forever()
except KeyboardInterrupt:
print("Keyboard interrupt received, stopping...")
if __name__ == '__main__':
run_server()