Reputation: 23098
I plan an app with client-side routing with React. The server serves these:
/
/register/*
/login/*
/api/*
The client-side router "serves":
/proposals
/projects
The issue is with initial requests hits server. An initial request for say /projects
hits server which responds with the static markup and client-side app.
How do I get Flask to serve the client-app when a request for a client-controlled route comes in? I can come up with the following, which involves declaring each client-route. Is there a better way?
app=...
app.configure_blueprint(api_blueprint)
@app.route("/projects/*")
@app.route("/proposals/*")
@app.route("/settings/*")
@app.route("/something/*")
def serve_app():
serve_static_markup()
Upvotes: 2
Views: 519
Reputation: 110
What about something like this:
@app.route('/')
@app.route("/<path:reqpath>")
def serve_app(reqpath):
serve_static_markup()
Upvotes: 1