From 23c5e3beec5bacb458f32cc756b8067fc603a4f8 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Wed, 26 Jun 2024 15:46:40 +0200 Subject: [PATCH] chg: [app] Added PROD setup and updated README with basic instructions --- README.md | 26 +++++++++++++++++++++++++- REQUIREMENTS | 3 ++- server.py | 6 ++++-- src/socket.js | 3 +-- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fbe6824..f16a825 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,30 @@ # misp-exercise-dashboard -This template should help get you started developing with Vue 3 in Vite. +## Installation +```bash +# Setup venv +python3 -m venv venv +source venv/bin/activate + +# Install deps +pip3 install -r REQUIREMENTS +``` + +## Running the PROD setup +```bash +python3 server.py +# Access the page http://localhost:3000 with your browser +``` + + +## Running the DEV setup +```bash +python3 server.py +``` +```bash +npm run dev +# Access the page provided by the output of the above command +``` ## Recommended IDE Setup diff --git a/REQUIREMENTS b/REQUIREMENTS index 05a40d7..de425fd 100644 --- a/REQUIREMENTS +++ b/REQUIREMENTS @@ -1,3 +1,4 @@ pyzmq python-socketio -eventlet \ No newline at end of file +eventlet +requests \ No newline at end of file diff --git a/server.py b/server.py index 3986609..2aa308a 100755 --- a/server.py +++ b/server.py @@ -10,7 +10,6 @@ from eventlet.green import zmq as gzmq import exercise as exercise_model import notification as notification_model -import config import db @@ -24,7 +23,10 @@ zsocket.setsockopt_string(gzmq.SUBSCRIBE, '') # Initialize Socket.IO server sio = socketio.Server(cors_allowed_origins='*', async_mode='eventlet') -app = socketio.WSGIApp(sio) +app = socketio.WSGIApp(sio, static_files={ + '/': {'content_type': 'text/html', 'filename': 'dist/index.html'}, + '/assets': './dist/assets', +}) @sio.event def connect(sid, environ): diff --git a/src/socket.js b/src/socket.js index 15e4456..64fa99a 100644 --- a/src/socket.js +++ b/src/socket.js @@ -20,8 +20,7 @@ export function resetState() { const MAX_LIVE_LOG = 30 // "undefined" means the URL will be computed from the `window.location` object -// const URL = process.env.NODE_ENV === "production" ? undefined : "http://localhost:3000"; -const URL = "http://localhost:3000"; +const URL = process.env.NODE_ENV === "production" ? undefined : "http://localhost:3000"; export const socket = io(URL, { autoConnect: true