Implemented static folder
This commit is contained in:
16
app.py
16
app.py
@ -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
10
www/index.html
Normal 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
1
www/main.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
console.debug('Main loaded!');
|
||||||
5
www/styles.css
Normal file
5
www/styles.css
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
body {
|
||||||
|
/* Anything but light mode, please. */
|
||||||
|
background-color: #000000;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user