mirror of
https://github.com/yeicor-3d/yet-another-cad-viewer.git
synced 2025-12-19 22:24:17 +01:00
Server implementation more or less complete
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
from OCP.TopoDS import TopoDS_Shape
|
||||
from aiohttp import web
|
||||
|
||||
from server import Server
|
||||
|
||||
server = Server()
|
||||
"""The server instance. This is the main entry point to serve CAD objects and other data to the frontend."""
|
||||
|
||||
if 'YACV_DISABLE_SERVER' not in os.environ:
|
||||
# Start a new server ASAP to let the polling client connect while still building CAD objects
|
||||
@@ -15,20 +16,16 @@ if 'YACV_DISABLE_SERVER' not in os.environ:
|
||||
server.start()
|
||||
|
||||
|
||||
def get_app() -> web.Application:
|
||||
def _get_app() -> web.Application:
|
||||
"""Required by aiohttp-devtools"""
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
from logo.logo import build_logo
|
||||
server.show_object(build_logo())
|
||||
server.show_object(build_logo(), 'logo')
|
||||
return server.app
|
||||
|
||||
|
||||
def show_object(obj: TopoDS_Shape):
|
||||
"""Show a CAD object in the default server"""
|
||||
server.show_object(obj)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Publish the logo to the server (reusing code from the aiohttp-devtools)
|
||||
get_app()
|
||||
_get_app()
|
||||
# Keep the server running for testing
|
||||
time.sleep(60)
|
||||
|
||||
Reference in New Issue
Block a user