librelist archives

« back to archive

Is there any option getting ipython command prompt while running flask ?

Is there any option getting ipython command prompt while running flask ?

From:
Rahul K P
Date:
2015-06-23 @ 07:15
>
> Let me try to explain my problem with example now.
>

Here is sample GUI code with Tkinter


> TkinterCode.py
> ~~~~~~~~~
> from Tkinter import *
> root = Tk()
> w = Label(root, text="Hello, world!")
> w.pack()
> root.mainloop()
>

If I run this code in Ipython, I don't get a command prompt when the GUI is
visible.
Now if I comment out the line, "root.mainloop()", the code still works in
Ipython and I have access to command prompt so that I can inspect data when
the code is running.

Now coming to the Flask case,


> FLaskCode.py
> ~~~~~~~~~~~
> from flask import Flask
> app = Flask(__name__)
>
> @app.route('/')
> def hello_world():
>     return 'Hello World!'
>     app.run()
>

When I run this application in Ipython, I don't get a command prompt. To
access variables while the code is running, I need to stop the flask
server.

Is there any option to run the flask server and have access to command
prompt?

Thank you

Re: [flask] Is there any option getting ipython command prompt while running flask ?

From:
vineet
Date:
2015-06-23 @ 07:23
Yes !!
It's possible using ipdb ,

1. Install ipdb using
pip install ipdb

2. Call set_trace () function in side of debug function

Example:
import ipdb
@app.route('/')
def hello_world():
    *ipdb.set_trace()*
    return 'Hello World!'
    app.run()


Best regards,
Vineet

On Tue, Jun 23, 2015 at 12:45 PM, Rahul K P <36rahu@gmail.com> wrote:

> Let me try to explain my problem with example now.
>>
>
> Here is sample GUI code with Tkinter
>
>
>> TkinterCode.py
>> ~~~~~~~~~
>> from Tkinter import *
>> root = Tk()
>> w = Label(root, text="Hello, world!")
>> *w.pack()*root.mainloop()
>>
>
> If I run this code in Ipython, I don't get a command prompt when the GUI
> is visible.
> Now if I comment out the line, "root.mainloop()", the code still works in
> Ipython and I have access to command prompt so that I can inspect data when
> the code is running.
>
> Now coming to the Flask case,
>
>
>> FLaskCode.py
>> ~~~~~~~~~~~
>> from flask import Flask
>> app = Flask(__name__)
>>
>> @app.route('/')
>> def hello_world():
>>     return 'Hello World!'
>>     app.run()
>>
>
> When I run this application in Ipython, I don't get a command prompt. To
> access variables while the code is running, I need to stop the flask
> server.
>
> Is there any option to run the flask server and have access to command
> prompt?
>
> Thank you
>

Re: [flask] Is there any option getting ipython command prompt while running flask ?

From:
Rahul K P
Date:
2015-06-23 @ 08:37
Thank you Vineet for replaying. But this is not sufficient for me. Right
now am working in Image Processing so we want to check variables while
running. So this ipdb method not going to work. And when i run interrupt
the working of flask application. Thanks for your valuable effort.

Regards
Rahul K P

Re: [flask] Is there any option getting ipython command prompt while running flask ?

From:
Dr. Tarique Sani
Date:
2015-06-23 @ 08:51
You can use the pdb Python Debugger. I never needed it but you can start
with the following two URLs
http://werkzeug.pocoo.org/docs/0.10/debug/

http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-debugging-testing-and-profiling


Cheers
T

On Tue, Jun 23, 2015 at 2:07 PM, Rahul K P <36rahu@gmail.com> wrote:

> Thank you Vineet for replaying. But this is not sufficient for me. Right
> now am working in Image Processing so we want to check variables while
> running. So this ipdb method not going to work. And when i run interrupt
> the working of flask application. Thanks for your valuable effort.
>
> Regards
> Rahul K P
>



-- 
=============================================================
Hire a CakePHP dev team : http://sanisoft.com
=============================================================