- 1. Create a simple Sanic app 0. Run with an ASGI server: $ uvicorn run_asgi:app or $ hypercorn run_asgi:app
- 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
- 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
- import asyncio import uvloop from sanic import Sanic, response app = Sanic("Example") @app.route("/") async def test(request): return response.json({"answer": "42"})
- import asyncio from signal import SIGINT, signal import uvloop from sanic import Sanic, response from sanic.server import AsyncioServer
- from os import getenv from sentry_sdk import init as sentry_init from sentry_sdk.integrations.sanic import SanicIntegration
- from sanic import Sanic from sanic.response import text from sanic.views import HTTPMethodView
- 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__":
- 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"
- 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