Contents

sanic

Contents

sanic 安装

python3 -m venv venv 
. venv/bin/activate
pip3 install sanic

helloworld

from sanic import Sanic
from sanic import text

app = Sanic("Myapp")


@app.get("/")
async def test(request):
    return text("hello world")

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8090, workers=4)

vscode debug

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "python": "${workspaceFolder}/venv/bin/python3",
            "program": "main.py",
            // "console": "integratedTerminal",
        }
    ]
}