2019-06-10 21:24:35 +00:00
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
2021-01-05 16:28:43 +00:00
|
|
|
from flask import Flask
|
2019-06-10 21:24:35 +00:00
|
|
|
|
2021-01-05 14:44:31 +00:00
|
|
|
from apiserver.config_repo import config
|
2021-01-05 16:28:43 +00:00
|
|
|
from apiserver.server_init.app_sequence import AppSequence
|
|
|
|
from apiserver.server_init.request_handlers import RequestHandlers
|
2019-06-10 21:24:35 +00:00
|
|
|
|
|
|
|
app = Flask(__name__, static_url_path="/static")
|
2021-01-05 16:28:43 +00:00
|
|
|
AppSequence(app).start(request_handlers=RequestHandlers())
|
2021-01-05 14:32:21 +00:00
|
|
|
|
2019-06-10 21:24:35 +00:00
|
|
|
|
|
|
|
# =================== MAIN =======================
|
|
|
|
if __name__ == "__main__":
|
|
|
|
p = ArgumentParser(description=__doc__)
|
|
|
|
p.add_argument(
|
|
|
|
"--port", "-p", type=int, default=config.get("apiserver.listen.port")
|
|
|
|
)
|
|
|
|
p.add_argument("--ip", "-i", type=str, default=config.get("apiserver.listen.ip"))
|
|
|
|
p.add_argument(
|
|
|
|
"--debug", action="store_true", default=config.get("apiserver.debug")
|
|
|
|
)
|
|
|
|
p.add_argument(
|
|
|
|
"--watch", action="store_true", default=config.get("apiserver.watch")
|
|
|
|
)
|
|
|
|
args = p.parse_args()
|
|
|
|
|
|
|
|
# logging.info("Starting API Server at %s:%s and env '%s'" % (args.ip, args.port, config.env))
|
|
|
|
|
|
|
|
app.run(
|
|
|
|
debug=args.debug,
|
|
|
|
host=args.ip,
|
|
|
|
port=args.port,
|
|
|
|
threaded=True,
|
|
|
|
use_reloader=args.watch,
|
|
|
|
)
|