-1

I want to Run a Flask Server inside a jupyter notebook for specific test and QA scenarios. I do understand that it is not wise to run a server inside notebook(As mentioned in the comments of this question).

However, I want to test a specific function that both requires a flask AppContext and a running server. It is a third-party API webhook handler and the third party does not have method to generate fake webhooks. While this might be a very specific case, I think this question is worth asking for edge cases like mine.

Mudassir
  • 725
  • 6
  • 28

1 Answers1

0

You can run a thread inside a block, with a target call of app.run. This will run the app in a separate thread.

from threading import Thread

Thread(target=app.run).start()

Restart the ipykernel as soon as you are done, and DO NOT in any circumstances use this in prduction

Mudassir
  • 725
  • 6
  • 28