mirror of https://github.com/encode/starlette.git
Update framework example in readme
This commit is contained in:
parent
645cc3089a
commit
44417775dc
12
README.md
12
README.md
|
@ -101,20 +101,16 @@ an ASGI toolkit. You can use any of its components independently.
|
||||||
from starlette.responses import PlainTextResponse
|
from starlette.responses import PlainTextResponse
|
||||||
|
|
||||||
|
|
||||||
class App:
|
async def app(scope, receive, send):
|
||||||
def __init__(self, scope):
|
|
||||||
assert scope['type'] == 'http'
|
assert scope['type'] == 'http'
|
||||||
self.scope = scope
|
|
||||||
|
|
||||||
async def __call__(self, receive, send):
|
|
||||||
response = PlainTextResponse('Hello, world!')
|
response = PlainTextResponse('Hello, world!')
|
||||||
await response(receive, send)
|
await response(scope, receive, send)
|
||||||
```
|
```
|
||||||
|
|
||||||
Run the `App` application in `example.py`:
|
Run the `app` application in `example.py`:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ uvicorn example:App
|
$ uvicorn example:app
|
||||||
INFO: Started server process [11509]
|
INFO: Started server process [11509]
|
||||||
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
|
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue