Skip to content

Commit

Permalink
Fixes on monitor app
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermedemouraa committed May 15, 2024
1 parent 7ec09ab commit 72e1bb6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
8 changes: 4 additions & 4 deletions py/examples/monitor_app/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"configs": [
{
"name": "gps",
"port": 3001,
"port": 50010,
"host": "localhost"
},
{
Expand All @@ -11,13 +11,13 @@
"host": "localhost"
},
{
"name": "oak0",
"name": "oak/0",
"port": 50010,
"host": "localhost"
},
{
"name": "oak1",
"port": 50011,
"name": "oak/1",
"port": 50010,
"host": "localhost"
},
{
Expand Down
6 changes: 5 additions & 1 deletion py/examples/monitor_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
from fastapi import FastAPI
from fastapi import WebSocket
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse
from fastapi.responses import JSONResponse
from fastapi.staticfiles import StaticFiles
from google.protobuf.json_format import MessageToJson

app = FastAPI()
Expand All @@ -40,6 +42,8 @@
allow_headers=["*"], # Allows all headers
)

app.mount("/static", StaticFiles(directory="./ts/dist"), name="static")

# to store the events clients
clients: dict[str, EventClient] = {}

Expand Down Expand Up @@ -81,7 +85,7 @@ async def subscribe(websocket: WebSocket, service_name: str, uri_path: str, ever

@app.get("/")
def read_root():
return {"Hello": "World"}
return FileResponse('./ts/dist/index.html')


if __name__ == "__main__":
Expand Down
20 changes: 15 additions & 5 deletions py/examples/monitor_app/ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
//plugins: [react()],
})
plugins: [react()],
base: '/static/', // Ensure this line is added
build: {
outDir: 'dist',
rollupOptions: {
output: {
assetFileNames: 'assets/[name].[hash].[ext]',
chunkFileNames: 'assets/[name].[hash].js',
entryFileNames: 'assets/[name].[hash].js',
},
},
},
});

0 comments on commit 72e1bb6

Please sign in to comment.