From ef8c0bc0c7d13e6051312bb517d0c1e4c641f882 Mon Sep 17 00:00:00 2001 From: Brandon Lyons Date: Fri, 8 Feb 2019 14:45:15 -0500 Subject: [PATCH] Add example showing how to get HTML5 history mode working with Flask. --- docs/guide/essentials/history-mode.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/guide/essentials/history-mode.md b/docs/guide/essentials/history-mode.md index 759c9ea16..8fb6d7473 100644 --- a/docs/guide/essentials/history-mode.md +++ b/docs/guide/essentials/history-mode.md @@ -122,6 +122,20 @@ Add this to your `firebase.json`: } ``` +#### Flask (Python) + +Add the following route to your application in the `__init__.py` file or wherever the app is instantiated. + +``` +@app.route('/', defaults={'path': ''}) +@app.route("/") +def index(): + """ + Serve vue main page. + """ + return render_template("index.html") +``` + ## Caveat There is a caveat to this: Your server will no longer report 404 errors as all not-found paths now serve up your `index.html` file. To get around the issue, you should implement a catch-all route within your Vue app to show a 404 page: