3

If possible I would like to run Flask from a Jupyter Notebook but I can't stop the application once it's running without restarting the kernel. Is there a way to do something equivalent to ctrl+c to stop the app from running in cell?

Here is what I'm doing:

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()

app.layout = html.Div(['This is the outermost div',
                      html.Div(['This is an inner div'],
                              style=dict(color='red')),
                      html.Div(['Another inner div'],
                              style=dict(color='blue'))],
                     style=dict(color='green',
                               border='2px green solid'))

app.run_server()

Which yields:

 * Serving Flask app "__main__" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
127.0.0.1 - - [02/Jan/2019 10:24:53] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [02/Jan/2019 10:24:54] "GET /_dash-layout HTTP/1.1" 200 -
127.0.0.1 - - [02/Jan/2019 10:24:54] "GET /_dash-dependencies HTTP/1.1" 200 -
127.0.0.1 - - [02/Jan/2019 10:24:54] "GET /_favicon.ico HTTP/1.1" 200 -

From Jupyter I'm unable to interrupt the kernel so to stop the app from running I need to restart the kernel. Is there a better way?

davidism
  • 121,510
  • 29
  • 395
  • 339
sparrow
  • 10,794
  • 12
  • 54
  • 74

1 Answers1

1

You Can press 'I' twice to interrupt the Kernel.

If you are running jupyter notebook from cmd/terminal you can press ctrl+c twice. It will stop the currently running cell. Before using Ctrl+C do remember to save your work as this step will stop the entire notebook.

For better understanding have a look at this answer.

Priyanka Jain
  • 471
  • 2
  • 11