kubeload/kubeload.py
2026-02-12 07:24:02 -08:00

35 lines
1.1 KiB
Python

from flask import Flask, send_from_directory, render_template
import os
import routes
app = Flask(__name__, static_folder="static", template_folder="templates")
# Enable template auto-reload
app.config['TEMPLATES_AUTO_RELOAD'] = True
# Absolute path to node_modules
NODE_MODULES_DIR = os.path.join(os.path.dirname(__file__), "node_modules")
# Serve the main page from templates
app.register_blueprint(routes.main)
app.register_blueprint(routes.account, url_prefix="/account")
app.register_blueprint(routes.auth)
app.register_blueprint(routes.products, url_prefix="/products")
# Serve files from the static folder
@app.route("/static/<path:filename>")
def serve_static(filename):
return send_from_directory(app.static_folder, filename) # type: ignore
# Serve files from node_modules
@app.route("/node_modules/<path:filename>")
def node_modules(filename):
file_path = os.path.join(NODE_MODULES_DIR, filename)
if os.path.exists(file_path):
return send_from_directory(NODE_MODULES_DIR, filename)
else:
return "File not found", 404
if __name__ == "__main__":
# Enable debug mode with reloader
app.run(debug=True)