Reputation: 139
I'm running a basic flask script from a jupyter notebook. I can access it through a web browser but the cell doesn't output the requests log unlike when the script is run from a commandline. Is there a way to display the log in the notebook.
here is the script
%load_ext ipyext.writeandexecute
%%writeandexecute -i myflask myflask.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
Upvotes: 1
Views: 5223
Reputation: 139
Just in case others face the same problem. I've gotten around this by opening a terminal from Jupyter
replace the writeandexecute magic with %%writefile myflask.py
and in a new cell
import subprocess as sub
# this opens a windows terminal
sub.call('start /wait python myflask.py', shell=True)
Upvotes: 4