Serving static sites
python -m http.server exposes a raw directory listing of the whole folder to anyone who opens the URL — looks broken and leaks more than intended. Use a two-line Flask app instead:
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route("/")
def index():
return send_from_directory(".", "index.html")
@app.route("/<path:path>")
def static_file(path):
return send_from_directory(".", path)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
pip install flask
Run it backgrounded from the folder containing the site, then open_port on 8000:
shell: cd /home/user/site && python app.py (background: true)
open_port: 8000