Application

At a minimum, the jetfactory.Application needs to be created with at least one Jetpack. Additional parameters can be provided to further customize the instance; see the docs below for more info.

API

class jetfactory.Application(packages=None, path='/api', settings=None, **kwargs)[source]

Creates a Jetfactory application

Parameters:
  • packages – List of (<path>, <package>)
  • path – Application root path
  • settings – Settings overrides
  • kwargs – kwargs to pass along to Sanic
run(host=None, port=None, workers=None, debug=False, sql_log=False, access_log=False, **kwargs)[source]

Starts the HTTP server

Parameters:
  • host – Listen host, defaults to 127.0.0.1
  • port – Listen port, defaults to 8080
  • workers – Number of workers, defaults to 1 per core.
  • debug – Debugging
  • sql_log – Log SQL-statements
  • access_log – Log requests
  • kwargs – Parameters to pass along to Sanic.run

Note

The jetfactory.Application and jetfactory.Application.run() can be configured using the environment and files as well.

Read more about this in the Configuration section.

Example

import jetfactory
import jet_apispec
import jet_guestbook

# Create application
app = jetfactory.Application(
    path='/api',
    packages=[
        ('/guestbook', jet_guestbook),
        ('/packages', jet_apispec)
    ]
)

# Start server
app.run(host='192.168.0.1')