-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pushing up code for poking at and debugging
- Loading branch information
Showing
8 changed files
with
410 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import logging | ||
|
||
from waitress.server import create_server | ||
from flask import Flask | ||
|
||
from config import microlabConfig as config | ||
|
||
|
||
class APIServer: | ||
|
||
_server = None | ||
|
||
def __init__(self, app: Flask): | ||
# self._server = make_server('0.0.0.0', config.apiPort, app) | ||
self._app = app | ||
# self.get_server(app) | ||
# ctx = app.app_context() | ||
# ctx.push() | ||
|
||
def run(self): | ||
logging.info('Starting backend server') | ||
# self._server.serve_forever() | ||
self.get_server(self._app).run() | ||
|
||
@classmethod | ||
def get_server(cls, app: Flask): | ||
if cls._server is None: | ||
cls._server = create_server(app, host='0.0.0.0', port=config.apiPort) | ||
return cls._server | ||
|
||
@classmethod | ||
def shutdown(cls): | ||
logging.info('Shutting down backend server') | ||
cls._server.close() | ||
logging.info('Shutting down backend server complete') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.