Implemented static folder

This commit is contained in:
2026-06-02 16:07:27 +01:00
parent 1f69f7921a
commit 4f6bd4dae2
4 changed files with 31 additions and 1 deletions

16
app.py
View File

@ -4,11 +4,25 @@ A simple Flask application for interacting with WHSPAH shockers.
import argparse import argparse
import logging import logging
import os
import waitress.server import waitress.server
import flask import flask
app = flask.Flask(__name__) app = flask.Flask(__name__, static_folder='./www/')
@app.route('/', defaults={'path': 'index.html'})
@app.route('/<path:path>')
def staticPage(path):
"""
Returns anything requested in the static folder.
"""
if os.path.isfile(os.path.join(app.static_folder, path, 'index.html')):
path = os.path.join(path, 'index.html')
return flask.send_from_directory(app.static_folder, path)
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()

10
www/index.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/styles.css">
<script src="/main.js"></script>
</head>
<body>
</body>
</html>

1
www/main.js Normal file
View File

@ -0,0 +1 @@
console.debug('Main loaded!');

5
www/styles.css Normal file
View File

@ -0,0 +1,5 @@
body {
/* Anything but light mode, please. */
background-color: #000000;
color: #FFFFFF;
}