app files restructure

This commit is contained in:
2024-11-14 11:46:50 +02:00
parent c07f0c25c5
commit 469a4b0383
312 changed files with 592 additions and 546 deletions

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env python
# Inspired by https://gist.github.com/jtangelder/e445e9a7f5e31c220be6
# Python3 http.server for Single Page Application
import urllib.parse
import http.server
import socketserver
import re
from pathlib import Path
port = 83
HOST = ('', port)
pattern = re.compile('.png|.jpg|.jpeg|.js|.css|.ico|.gif|.svg|.ico', re.IGNORECASE)
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
url_parts = urllib.parse.urlparse(self.path)
request_file_path = Path(url_parts.path.strip("/"))
ext = request_file_path.suffix
if not request_file_path.is_file() and not pattern.match(ext):
self.path = 'index.html'
return http.server.SimpleHTTPRequestHandler.do_GET(self)
httpd = socketserver.TCPServer(HOST, Handler)
print(f"Starting Web App Server on pot: {port}")
httpd.serve_forever()

18
Frontend/server/server.sh Normal file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Define the port
PORT=83
# Check if the port is in use and release it if necessary.
# echo "Checking if port $PORT is in use..."
# if [ "$(lsof -t -i :$PORT)" ]; then
# echo "Port $PORT is in use. Stopping the process on that port..."
# fuser -k -n tcp $PORT
# fi
# Switch to the web construction directory
cd /app/build/web/
# Start the web server on the specified port
#python3 -m http.server 83
python3 -u ../../server/MIH_web_server.py