1Single-Page Applications 2======================== 3 4Flask can be used to serve Single-Page Applications (SPA) by placing static 5files produced by your frontend framework in a subfolder inside of your 6project. You will also need to create a catch-all endpoint that routes all 7requests to your SPA. 8 9The following example demonstrates how to serve an SPA along with an API:: 10 11 from flask import Flask, jsonify 12 13 app = Flask(__name__, static_folder='app', static_url_path="/app") 14 15 16 @app.route("/heartbeat") 17 def heartbeat(): 18 return jsonify({"status": "healthy"}) 19 20 21 @app.route('/', defaults={'path': ''}) 22 @app.route('/<path:path>') 23 def catch_all(path): 24 return app.send_static_file("index.html") 25