openfisca serve

usage: openfisca serve [-h] [-c COUNTRY_PACKAGE]
                       [-e [EXTENSIONS [EXTENSIONS ...]]]
                       [-r [REFORMS [REFORMS ...]]] [-p PORT]
                       [--tracker-url TRACKER_URL]
                       [--tracker-idsite TRACKER_IDSITE]
                       [--tracker-token TRACKER_TOKEN]
                       [--welcome-message WELCOME_MESSAGE]
                       [-f CONFIGURATION_FILE]

Named Arguments

-c, –country-package
 country package to use. If not provided, an automatic detection will be attempted by scanning the python packages installed in your environment which name contains the word “openfisca”.
-e, –extensions
 extensions to load
-r, –reforms reforms to apply to the country package
-p, –port port to serve on (use –bind to specify host and port)
–tracker-url tracking service url
–tracker-idsite
 tracking service id site
–tracker-token
 tracking service authentication token
–welcome-message
 welcome message users will get when visiting the API root
-f, –configuration-file
 configuration file

Additional arguments

openfisca serve uses gunicorn under the hood. In addition to the arguments listed above, you can use any gunicorn arguments when running openfisca serve (e.g. --reload, --workers, --timeout, --bind). See:

gunicorn --help

Examples

Basic use

openfisca serve --country-package openfisca_france

Serving extensions

openfisca serve --country-package openfisca_france --extensions openfisca_paris

Serving reforms

openfisca serve --country-package openfisca_france --reforms openfisca_france.reforms.plf2015.plf2015

Using a configuration file

You can setup openfisca serve using a configuration file. Be careful as parameters with a ‘-‘ in their name on command line change to an ‘_’ when used from the config file. See this example of configuration:

config.py:

port = 4000
workers = 4
bind = '0.0.0.0:{}'.format(port)
country_package = 'openfisca_france'
extensions = ['openfisca_paris']

Command line:

openfisca serve --configuration-file config.py