sanic asgi

1. Create a simple Sanic app 0. Run with an ASGI server:       $ uvicorn run_asgi:app        or       $ hypercorn run_asgi:app

matplotlib SpanSelector

The SpanSelector is a mouse widget to select a xmin/xmax range and plot the detail view of the selected region in the lower axes

matplotlib widgets textbox

The Textbox widget lets users interactively provide text input, including formulas. In this example, the plot is updated using the `.on_submit` method. This method triggers the execution of the *submit* function when the user presses enter in the textbox

sanic async

import asyncio import uvloop from sanic import Sanic, response app = Sanic("Example") @app.route("/") async def test(request): return response.json({"answer": "42"})

sanic async advanced

import asyncio from signal import SIGINT, signal import uvloop from sanic import Sanic, response from sanic.server import AsyncioServer

sanic sentry

from os import getenv from sentry_sdk import init as sentry_init from sentry_sdk.integrations.sanic import SanicIntegration

sanic async view

from sanic import Sanic from sanic.response import text from sanic.views import HTTPMethodView

sanic socket

import os import socket from sanic import Sanic, response app = Sanic("Example") @app.route("/test") async def test(request): return response.text("OK") if __name__ == "__main__":

sanic blueprint group

from sanic import Sanic from sanic.blueprints import Blueprint from sanic.response import json app = Sanic(name="blue-print-group-version-example") bp1 = Blueprint(name="ultron", url_prefix="/ultron") bp2 = Blueprint(name="vision", url_prefix="/vision"

sanic vhosts

from sanic import Sanic, response from sanic.blueprints import Blueprint # Usage # curl -H "Host: example.com" localhost:8000 # curl -H "Host: sub.example.com" localhost:8000 # curl -H "Host: bp.example.com" localhost:8000/question