I’m doing a sample ecommerce site for a web dev course I am in.
I got into JAMStack recently so I decided to use it as a way to build my site, but I am not sure how to use the backend.
I know I can use Flask and Hugo servers separately and have an nginx reverse proxy but I want to serve hugo directly through flask.
from flask import Flask, send_from_directory
app = Flask(__name__)
@app.route('/')
def index():
return send_from_directory('static/public', 'index.html')
@app.route('/<path:filename>')
def static_files(filename):
# Prevent adding "index.html" to paths of HTML, CSS, JS, and image files
if not filename.endswith(('.html', '.css', '.js','svg', '.jpg', '.png', '.gif')):
filename += "/index.html"
return send_from_directory('static/public', filename)
if __name__ == '__main__':
app.run(debug=True)
This is my starting code, does anyone have any advice on whether this is a good idea or should I use reverse proxy or any other method?