I have my Flask app initialized like this:
app = Flask(__name__, static_folder="../static/dist", template_folder="../static")
For the moment, I want to catch all routes and render the same template (which is a React app):
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def any_root_path(path):
return render_template('index.html')
This works for all URLs having only one slash, as my static folder is located one step up. Example: localhost:5000/home gets the static folder at:
localhost:5000/static
However when I try to access paths with more than one slash (for example localhost:5000/home/whatever), Flask tries to get the static folder with the path
localhost:5000/home/static/dist
What I want is to set the static_folder path as the same throughout, and not relative to the Route matched. Is this possible? Have I misunderstood something?
My file structure for reference:
my_app/
server/
app.py/ # my Flask app
static/
dist/
someJavascript.js
index.html