How to use the hypercorn.asyncio.serve function in Hypercorn

To help you get started, we’ve selected a few Hypercorn 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 rob-blackbourn / bareasgi / examples / rest.py View on Github external
if USE_UVICORN:
        uvicorn.run(
            app,
            host='0.0.0.0',
            port=9009,
            ssl_keyfile=keyfile,
            ssl_certfile=certfile
        )
    else:
        config = Config()
        config.bind = ["0.0.0.0:9009"]
        config.loglevel = 'debug'
        # config.certfile = certfile
        # config.keyfile = keyfile
        asyncio.run(serve(app, config))
github rob-blackbourn / bareasgi / examples / simple_web_page.py View on Github external
certfile = os.path.expanduser(f"~/.keys/{hostname}.crt")
    keyfile = os.path.expanduser(f"~/.keys/{hostname}.key")

    if USE_UVICORN:
        uvicorn.run(app, host='0.0.0.0', port=9009,
                    ssl_keyfile=keyfile, ssl_certfile=certfile)
    else:
        config = Config()
        config.bind = ["0.0.0.0:9009"]
        config.loglevel = 'debug'
        config.certfile = certfile
        config.keyfile = keyfile
        # config.verify_flags = ssl.VERIFY_X509_TRUSTED_FIRST
        # config.verify_mode = ssl.CERT_NONE
        # config.ciphers = "TLSv1"
        asyncio.run(serve(app, config))
        # Options.OP_ALL|OP_NO_SSLv3|OP_NO_SSLv2|OP_CIPHER_SERVER_PREFERENCE|OP_SINGLE_DH_USE|OP_SINGLE_ECDH_USE|OP_NO_COMPRESSION
github osks / httpkom / httpkom / __main__.py View on Github external
def run_http_server(args):
    os.environ['HTTPKOM_SETTINGS'] = args.config
    init_app(app)
    config = Config()
    config.bind = ["{}:{}".format(args.host, args.port)]
    asyncio.run(serve(app, config))
github LonamiWebs / Telethon / telethon_examples / quart_login.py View on Github external
async def main():
    await hypercorn.asyncio.serve(app, hypercorn.Config())
github rob-blackbourn / bareasgi / examples / http_push.py View on Github external
app.http_router.add({'GET'}, '/clickHandler.js', test_asset)

    import uvicorn
    from hypercorn.asyncio import serve
    from hypercorn.config import Config

    USE_UVICORN = False

    if USE_UVICORN:
        uvicorn.run(app, port=9009)
    else:
        config = Config()
        config.bind = ["ugsb-rbla01.bhdgsystematic.com:9009"]
        config.certfile = "/home/BHDGSYSTEMATIC.COM/rblackbourn/.keys/ugsb-rbla01.crt"
        config.keyfile = "/home/BHDGSYSTEMATIC.COM/rblackbourn/.keys/ugsb-rbla01.key"
        asyncio.run(serve(app, config))
github rob-blackbourn / bareasgi / examples / lifespan.py View on Github external
from hypercorn.config import Config
        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)

        shutdown_event = asyncio.Event()

        def _signal_handler(*_: Any) -> None:
            shutdown_event.set()
        loop.add_signal_handler(signal.SIGTERM, _signal_handler)
        loop.add_signal_handler(signal.SIGINT, _signal_handler)

        config = Config()
        config.bind = ["0.0.0.0:9009"]
        loop.run_until_complete(
            serve(
                app,
                config,
                shutdown_trigger=shutdown_event.wait  # type: ignore
            )
github rob-blackbourn / bareasgi / examples / server_sent_events_simple.py View on Github external
from hypercorn.config import Config
        asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)

        shutdown_event = asyncio.Event()

        def _signal_handler(*_: Any) -> None:
            shutdown_event.set()
        loop.add_signal_handler(signal.SIGTERM, _signal_handler)
        loop.add_signal_handler(signal.SIGINT, _signal_handler)

        config = Config()
        config.bind = ["0.0.0.0:9009"]
        loop.run_until_complete(
            serve(
                app,
                config,
                shutdown_trigger=shutdown_event.wait  # type: ignore
            )
github rob-blackbourn / bareasgi / examples / streaming_fetch.py View on Github external
shutdown_event = asyncio.Event()

    def _signal_handler(*_: Any) -> None:
        shutdown_event.set()
    loop.add_signal_handler(signal.SIGTERM, _signal_handler)
    loop.add_signal_handler(signal.SIGINT, _signal_handler)

    config = Config()
    config.bind = ["0.0.0.0:9009"]
    config.loglevel = 'debug'
    # config.certfile = os.path.expanduser(f"~/.keys/server.crt")
    # config.keyfile = os.path.expanduser(f"~/.keys/server.key")

    loop.run_until_complete(
        serve(
            app,
            config,
            shutdown_trigger=shutdown_event.wait  # type: ignore
        )
github pgjones / quart / src / quart / app.py View on Github external
if debug is not None:
            self.debug = debug
        config.errorlog = config.accesslog
        config.keyfile = keyfile
        config.use_reloader = use_reloader

        scheme = "https" if config.ssl_enabled else "http"
        print(  # noqa: T001, T002
            "Running on {}://{} (CTRL + C to quit)".format(scheme, config.bind[0])
        )

        if loop is not None:
            loop.set_debug(debug or False)
            loop.run_until_complete(serve(self, config))
        else:
            asyncio.run(serve(self, config), debug=config.debug)