78e912ea45
* Remove raw_args from docs (deprecated feature removed in Sanic 20.3). * Add missing Sanic(name) arguments in docs. Merge async/non-async class view examples. Co-authored-by: L. Kärkkäinen <tronic@users.noreply.github.com>
54 lines
1.3 KiB
ReStructuredText
54 lines
1.3 KiB
ReStructuredText
Debug Mode
|
|
=============
|
|
|
|
When enabling Sanic's debug mode, Sanic will provide a more verbose logging output
|
|
and by default will enable the Auto Reload feature.
|
|
|
|
.. warning::
|
|
|
|
Sanic's debug more will slow down the server's performance
|
|
and is therefore advised to enable it only in development environments.
|
|
|
|
|
|
Setting the debug mode
|
|
----------------------
|
|
|
|
By setting the ``debug`` mode a more verbose output from Sanic will be output
|
|
and the Automatic Reloader will be activated.
|
|
|
|
.. code-block:: python
|
|
|
|
from sanic import Sanic
|
|
from sanic.response import json
|
|
|
|
app = Sanic(__name__)
|
|
|
|
@app.route('/')
|
|
async def hello_world(request):
|
|
return json({"hello": "world"})
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host="0.0.0.0", port=8000, debug=True)
|
|
|
|
|
|
|
|
Manually setting auto reload
|
|
----------------------------
|
|
|
|
Sanic offers a way to enable or disable the Automatic Reloader manually,
|
|
the ``auto_reload`` argument will activate or deactivate the Automatic Reloader.
|
|
|
|
.. code-block:: python
|
|
|
|
from sanic import Sanic
|
|
from sanic.response import json
|
|
|
|
app = Sanic(__name__)
|
|
|
|
@app.route('/')
|
|
async def hello_world(request):
|
|
return json({"hello": "world"})
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host="0.0.0.0", port=8000, auto_reload=True)
|