2021-10-28 03:54:04 +03:00
|
|
|
from sanic import Sanic
|
|
|
|
from sanic.response import file
|
|
|
|
|
2021-11-04 02:41:34 +02:00
|
|
|
from InputController import InputController
|
2021-10-28 03:54:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
app = Sanic("capybara")
|
|
|
|
|
2021-11-04 02:41:34 +02:00
|
|
|
app.ctx.input_controller = InputController()
|
2021-11-03 04:21:58 +02:00
|
|
|
app.static("app", "frontend/dist/", resource_type="dir")
|
2021-10-28 03:54:04 +03:00
|
|
|
|
2021-11-04 02:41:34 +02:00
|
|
|
|
2021-10-28 03:54:04 +03:00
|
|
|
@app.websocket("/gateway")
|
|
|
|
async def gateway(req, ws):
|
|
|
|
while True:
|
|
|
|
app.ctx.input_controller.process_message(await ws.recv())
|
|
|
|
|
2021-11-04 02:41:34 +02:00
|
|
|
|
2021-10-28 03:54:04 +03:00
|
|
|
def main():
|
|
|
|
app.run(host='0.0.0.0', port=4003, access_log=False)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|