-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
158cf16
commit 76fce02
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import sanic | ||
|
||
# hello world example | ||
app = sanic.Sanic("MySanic") | ||
|
||
@app.route("/") | ||
async def test(request): | ||
return sanic.response.text("Hello, world.") | ||
|
||
if __name__ == "__main__": | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import httpx, asyncio | ||
from httpx import AsyncClient, Headers | ||
|
||
client = AsyncClient() | ||
|
||
async def main(): | ||
res = await client.get("http://localhost:8000/") | ||
print(res.text) | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from sanic import Blueprint | ||
from sanic.response import text | ||
from sanic import Sanic | ||
|
||
app = Sanic('test') | ||
|
||
bpv1 = Blueprint('bpv1', version=1) | ||
|
||
@bpv1.route('/hello') | ||
async def root(request): | ||
return text('hello v1') | ||
|
||
app.blueprint(bpv1) | ||
|
||
bpv2 = bpv1.copy('bpv2', version=2, allow_route_overwrite=True) | ||
|
||
@bpv2.route('/hello') | ||
async def root(request): | ||
return text('hello v2') | ||
|
||
app.blueprint(bpv2) | ||
|
||
if __name__ == '__main__': | ||
app.run() |