How to use the daphne.server function in daphne

To help you get started, we’ve selected a few daphne examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hivesolutions / appier / src / appier / asgi.py View on Github external
def serve_daphne(self, host, port, **kwargs):
        util.ensure_pip("daphne")
        import daphne.server
        import daphne.cli
        self.server_version = daphne.__version__
        app_asgi = build_asgi_i(self)
        app_daphne = daphne.cli.ASGI3Middleware(app_asgi)
        self._server = daphne.server.Server(
            app_daphne,
            endpoints = ["tcp:port=%d:interface=%s" % (port, host)]
        )
        self._server.run()
github django / channels / channels / apps.py View on Github external
from django.apps import AppConfig

# We import this here to ensure the reactor is installed very early on
# in case other packages accidentally import twisted.internet.reactor
# (e.g. raven does this).
import daphne.server

assert daphne.server  # pyflakes doesn't support ignores


class ChannelsConfig(AppConfig):

    name = "channels"
    verbose_name = "Channels"

    def ready(self):
        # Do django monkeypatches
        from .hacks import monkeypatch_django

        monkeypatch_django()