I am new on web app development.
My question is ... I have tried some hand-on development on Zend + Apache(php) , Flask(python), Express under node.js.
I found that when I start doing development on Zend framework + Apache, there is no need to restart the apache every time when there is code change in PHP under Controller, Model or Views. It is very convenient and fast!
However, if I work on Flask or Express, I have to restart the whole application everytime when i change code on Controller or Model part. There is no need to restart the server if there is code change on View parts. However, it is annoying enough!!!
Right now, i am working on the project on Flask, how can I avoid the restart the server everytime??? Can the problem be solved if i put the whole web app on top of Nginx??
Thanks a lot
UPDATE:
When debug mode is on for Flask, the server will detect for changes::
from application import app
app.debug = True
if __name__ == '__main__':
app.run()
However, in production setting, it is not recommended to auto-refresh the server.
Run it on top of tornado
:
$ pip install tornado
Create a new file server.py
, which wrap up the 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()
If running with mod_wsgi, you just need to change or touch the WSGI script that WSGIScriptAlias
points to.
touch /home/user/env/app.wsgi
See http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With