Skip to main content

Flask-like extension support for Sanic framework

Project description

Flask-like extension support for Sanic framework

Features

  • Flask-like style initializing and using with Sanic applications

  • Easy to write a new extension and use it later

Installation

This package should be installed using pip:

pip install sanic-base-extension

Example

from sanic import Sanic
from sanic_base_ext import BaseExtension


class CustomExtension(BaseExtension):
    extension_name = app_attribute = 'custom'

    def hello(self, user):
        print("Hello, {}!".format(user))


app = Sanic(__name__)
CustomExtension(app)  # available via `app.custom` or `app.extensions['custom']`
app.ctx.custom.hello('world')  # Hello, world!

License

The sanic-base-extension is published under BSD license. For more details read LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sanic-base-extension-0.2.0.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file sanic-base-extension-0.2.0.tar.gz.

File metadata

  • Download URL: sanic-base-extension-0.2.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for sanic-base-extension-0.2.0.tar.gz
Algorithm Hash digest
SHA256 644665332be85932378bd57babe968bb92bd02d0963d1dee55d2a4b47e9127ec
MD5 f35f00937cfd78a50c90a5efaa64457b
BLAKE2b-256 5796f5b2df0937b672a14b60b8c3c88c7114ed6ad3eb94976ff0dac498ae6d3c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page