From e1af62cdc7db01f68445cd50f284627246d93d12 Mon Sep 17 00:00:00 2001 From: kngwyu Date: Mon, 19 Apr 2021 20:15:33 +0900 Subject: [PATCH] Use Python string for HTML --- mujoco_maze/static/index.html | 27 --------------------------- mujoco_maze/websock_viewer.py | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 mujoco_maze/static/index.html diff --git a/mujoco_maze/static/index.html b/mujoco_maze/static/index.html deleted file mode 100644 index ed58d17..0000000 --- a/mujoco_maze/static/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - MuJoCo maze visualizer - - - -
- -
- - diff --git a/mujoco_maze/websock_viewer.py b/mujoco_maze/websock_viewer.py index 9dad232..07b82d0 100644 --- a/mujoco_maze/websock_viewer.py +++ b/mujoco_maze/websock_viewer.py @@ -1,13 +1,42 @@ import asyncio import io import multiprocessing as mp -import pathlib import fastapi import uvicorn from PIL import Image +HTML = """ + + + + MuJoCo maze visualizer + + + +
+ +
+ + +""" + class _ServerWorker(mp.Process): def __init__(self, pipe: mp.connection.Pipe, port: int) -> None: @@ -18,9 +47,7 @@ class _ServerWorker(mp.Process): def _run_server(self) -> None: app = fastapi.FastAPI() - static = pathlib.Path(__file__).parent.joinpath("static") - html_path = static.joinpath("index.html") - html = html_path.read_text().replace("{{port}}", str(self.port)) + html = HTML.replace("{{port}}", str(self.port)) @app.get("/") async def get():