Hi guys. I’m building a web app with Elm as the frontend and flask as the backend. The app consists of a home page and several tutorial pages linked from it. The only issue is this:
In the home page, click on the left-most button to enter the first tutorial
Refresh the page or directly visit the URL in step 2 and you will get a page not found error.
However, the above issue never happens when I tested the app using elm-live on localhost. Does it have anything to do with how flask and elm-live serve files differently? How can I fix this? Thanks.
This is because the server doesn’t recognise the paths e.g. /tutorial/
You server needs to accept any path and server the Elm application.
e.g. if you hit /tutorial/, the backend needs to serve an html with the Elm app
Following Sebastian’s solution, you could use flask’s method render_template('some_html_file.html') (returning it from the view method that catches your route) and then initialize your elm app from there.