Giter VIP home page Giter VIP logo

Comments (8)

miguelgrinberg avatar miguelgrinberg commented on September 8, 2024

Can you give me more details?

I'm not sure I understand, because when you run the application in debug mode any time the source files change the application restarts on its own, there shouldn't be a need for you to remember to do that.

from flasky.

morpheme avatar morpheme commented on September 8, 2024

Ah, I didn't realize that. That does make a difference, as I am running your tutorial in a Vagrant environment and despite my efforts otherwise, I can't seem to get debug mode to work. Having said that, I haven't tried it since the option to specify the host through the command line was introduced. I will get back on my dev machine ASAP and report back in further detail.

from flasky.

morpheme avatar morpheme commented on September 8, 2024

Ok, now that I am in front of my machine and your book I see that runserver starts the web server in debug mode -- I had forgotten that detail.

So my Vagrantfile has this in it:

config.vm.network :forwarded_port, guest: 5000, host: 5000

but from the beginning of the tutorial/book, when I was doing

if __name__ == '__main__':
     app.run()

I was not ever able to get the debug=True argument to app.run() work. (I believe I got a 500 error in the browser, but I might not be remembering that correctly.) I eventually realized that doing app.run(host='0.0.0.0') would work, and I didn't try to troubleshoot further as I didn't want to get sidetracked. And it seems that debug still isn't an option for me, as indicated upthread. I now have

if __name__ == '__main__':
     manager.run()

(with Manager properly imported and set), and I am just issuing $ python hello.py runserver --host 0.0.0.0 but I apparently am not able to reap the benefits of being in debug mode.

In short, it seems that me with my Vagrant issue is somewhat of an edge case, and again, as long as I remember to re-load the python script there won't be an issue as far as that goes. If you are willing/able to figure out how to adjust Vagrantfile settings to allow for debug mode to actually be enabled, that's awesome -- but, I perfectly understand if you have other fish to fry! For myself, I learned just enough Vagrant to get myself an isolated environment for projects like your tutorial, and I will have to revisit later when my immediate objective is accomplished.

from flasky.

miguelgrinberg avatar miguelgrinberg commented on September 8, 2024

Do you get these lines printed in the Vagrant console when you start the server?

 * Running on http://0.0.0.0:5000/
 * Restarting with reloader

If you do, then open a second console and make a small edit in one of the .py files. That should trigger the app to restart, and the first console should print a message with the file that changed.

This should work, regardless of your use of Vagrant or the networking configuration that you are using.

from flasky.

miguelgrinberg avatar miguelgrinberg commented on September 8, 2024

Actually, I think I just figured the problem out. It looks like the current release of Flask-Script is broken, it always disables debug mode.

Try downgrading to 0.6.6, the version I used back when I developed Flasky and let me know if that addresses the problem.

from flasky.

morpheme avatar morpheme commented on September 8, 2024

Miguel, you rock. That did it. I tested both app.run(host='0.0.0.0') and manager.run() at first and verified that I was not seeing the second line * Restarting with reloader. I then issued pip freeze and verified that the Flask-Script version was 2.0.3, so I then issued sudo pip uninstall flask-script and sudo pip install flask-script==0.6.6. At that point, running hello.py with manager.run() showed that previously missing line in the console, and after I made a slight edit to hello.py (and saved it), I saw that it detected the change and reloaded. I think I'm good. Thanks again!

from flasky.

miguelgrinberg avatar miguelgrinberg commented on September 8, 2024

Glad you are up and running. For your reference, this is the Flask-Script bug: smurfix/flask-script#91. The bug was fixed, but in a backwards incompatible way. I hope I can convince the developer to correct the situation.

from flasky.

morpheme avatar morpheme commented on September 8, 2024

Indeed; I can certainly understand that it's a pain for this to come up after you've already put the book to bed.

from flasky.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.