When the code be changed with DEBUG=True,Server will reload like flask.
Why not do that?
You can use sanic-admin
I've already written a tool to manage it. Thank your help.
But I think it would be better if sanic built this feature.
You can use the library AoikLiveReload to do that.
Take a look at the demo here:
https://github.com/AoiKuiyuyou/AoikLiveReload/blob/master/src/aoiklivereload/demo/sanic_demo.py
To enable auto reloading developer must pass "auto_reload=True" to "run" method of Sanic app.
Really? I don't know that but I will try soon after class. I'm a student😳
@Yaser-Amiri
Hey, I try it, but get a TypeError
Traceback (most recent call last):
File "main.py", line 55, in <module>
main.run("0.0.0.0", 8000, debug=True, auto_reload=True)
TypeError: run() got an unexpected keyword argument 'auto_reload'
Is there anything I've overlooked?
Thank your help. Don't have this parameter in the version I installed with PIP. I will update Sanic from github. @yunstanford
@Yaser-Amiri can you double check the unit test here ? https://github.com/channelcat/sanic/blob/master/tests/test_auto_reload.py
it's actually failing on my side, and might also try refactor a little bit, it's not very pytest style.
@yunstanford Sorry about late.
I pulled repo now and ran tests, all tests passed (Python 3.6) and auto-reloading works correctly. About refactoring you are right, it's not very pytest style and I'll refactor it as soon as possible.
Most helpful comment
To enable auto reloading developer must pass "auto_reload=True" to "run" method of Sanic app.