How not to restart the server every time when working with Flask or Express?

I am new to web application development.

My question is ... I tried some kind of manual development on Zend + Apache (php), Flask (python), Express under node.js.

I found that when I start developing the Zend framework + Apache, there is no need to restart apache every time I change the code in PHP under the controller, model or views. It is very convenient and fast!

However, if I am working on Flask or Express, I have to restart the entire application every time I change the code on the controller or part of the model. There is no need to restart the server when changing the code in the "View Details" section. However, this is annoying enough !!!

Right now, I am working on a project on Flask, how can I avoid restarting the server every time ??? Can the problem be solved if I put the entire web application on top of Nginx ??

thanks a lot

+6
source share
3 answers

UPDATE:

When debugging mode is enabled for Flask, the server will detect the changes:

from application import app app.debug = True if __name__ == '__main__': app.run() 

However, when tuning performance, it is not recommended to automatically update the server.


Run it on top of tornado :

 $ pip install tornado 

Create a new server.py file that terminates app.py :

 from tornado import autoreload from tornado.wsgi import WSGIContainer from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop http_server = HTTPServer(WSGIContainer(app)) http_server.listen(5000) ioloop = IOLoop.instance() autoreload.start(ioloop) ioloop.start() 
+6
source

If you use mod_wsgi, you just need to change or touch the WSGI script that WSGIScriptAlias points WSGIScriptAlias .

 touch /home/user/env/app.wsgi 

See http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

+2
source

If you run with debugger , you can use the restart command to restart the script without restarting the entire server.

0
source

Source: https://habr.com/ru/post/909652/


All Articles