Running our application
Now that we have laid our application foundations, we are almost ready to run our server. We are going to make one small change to server.py
to include a small little utility to run at startup to show us what routes are registered:
from .utilities.app_factory import create_app from sanic.log import logger app = create_app() @app.main_process_start def display_routes(app, _): logger.info("Registered routes:") for route in app.router.routes: logger.info(f"> /{route.path}")
You can head over to the GitHub repository, https://github.com/PacktPublishing/Python-Web-Development-with-Sanic/tree/main/Chapter02, to see the full source code.
We can now start our application for the first time. Remember, this is going to be our pattern:
$ sanic src.server:app -p 7777 --debug --workers=2
We should see something like this:
[2021-05-30 11...