2024-09-30 18:40:26 +00:00
|
|
|
# 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
|
2024-10-03 22:31:31 +00:00
|
|
|
from .routes import interface_routes, formatter_routes, redirect_routes
|
2024-09-30 18:40:26 +00:00
|
|
|
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
|
2024-10-03 22:31:31 +00:00
|
|
|
|
|
|
|
api.register_blueprint(redirect_routes)
|
2024-09-30 18:40:26 +00:00
|
|
|
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()
|