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/") def serve_static(filename): return send_from_directory(app.static_folder, filename) # type: ignore # Serve files from node_modules @app.route("/node_modules/") 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)