In my app, I have implemented a catch all mechanism in flask backend according to the sample code in http://flask.pocoo.org/snippets/57/
The idea is to handle all routing by my frontend code (vue router, if that is relevant). I have several other routes in my flask code, but they should only be called by ajax calls.
Unfortunately, it does not work as I expected. Either I am doing something wrong, or I do not understand the catch all mechanism. This is what I have in my flask code currently:
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
return render_template("index.html")
@app.route("/test", methods=['GET'])
def get_def():
return jsonify(tst="dummy")
Now, if I enter https://weisswurst.pythonanywhere.com/test, I would expect the flask catch all code to render my index.html file, so my frontend router can handle it (it should route to a customized 404 page). But instead I get a page showing {"tst":"dummy"}, so apparently the /test route was triggered by entering the url manually.
What am I doing wrong?