HTTP Configuration¶
In order to be able to define routes, we will need a configuration
helper that will hold the router configuration until the score.http
module is initialized. We will define this helper in the file
moswblog/http.py:
from score.http import RouterConfiguration
router = RouterConfiguration()
And now the configuration. Note, that we will only add score.http (and
its dependency score.ctx) to the list of modules to initialize. The
other module—score.serve—is not part of our blogging application, it is
just a helper: it will serve our application during development. We might even
choose a different method in production.
Edit the configuration file dev.conf:
[score.init]
modules =
moswblog
score.sa.db
score.sa.orm
score.ctx
score.http
...
[http]
router = moswblog.http.router
[serve]
modules = http
autoreload = true
We need these modules installed, too, so let’s add them to our setup.py:
install_requires=[
'score.init',
'score.sa.db',
'score.sa.orm',
'score.shell',
'score.ctx',
'score.http',
'score.serve',
'sqlalchemy_utils',
'passlib',
'PyYAML',
'docutils',
],
Again, we will have to re-install our package after changing its dependencies:
$ pip install -e .
Since everything is in place now, we can start the moswblog http server.