-
Hi all, I have a bit of a niche use case, but hopefully someone here can help. I have a flask app with an endpoint, say @app.route("/1"). When this API is called, I want to create a second endpoint in the same flask app, say @app.route("/2") (by modifying the .py file directly), reload the script, call the new API, and run some other code from there. However on doing so, the first process is terminated, which is not what I desire. Is there any way to add a new endpoint while allowing the current process to continue running? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can't do that, it's not how routes are supposed to work. Instead, create routes (or a route with a variable part) ahead of time, and use a database, the session, redis, etc. to track information about what should be happening at any given time. For example, when accessing the first route, check that a flag hasn't been set, and when accessing the second check that it has. |
Beta Was this translation helpful? Give feedback.
You can't do that, it's not how routes are supposed to work. Instead, create routes (or a route with a variable part) ahead of time, and use a database, the session, redis, etc. to track information about what should be happening at any given time. For example, when accessing the first route, check that a flag hasn't been set, and when accessing the second check that it has.