From b7ef8faf1baa9d10a5ff4af886ba89dc5485b9fc Mon Sep 17 00:00:00 2001
From: Tom Christie
— âï¸ —
+ +Starlette is a small library for + ```python from starlette import Response @@ -108,6 +112,8 @@ class App: await response(receive, send) ``` +— âï¸ —
+ ## Requests Starlette includes a `Request` class that gives you a nicer interface onto @@ -133,7 +139,7 @@ class App: The request method is accessed as `request.method`. -### URL +#### URL The request URL is accessed as `request.url`. @@ -142,19 +148,19 @@ components that can be parsed out of the URL. For example: `request.url.path`, `request.url.port`, `request.url.scheme`. -### Headers +#### Headers Headers are exposed as an immutable, case-insensitive, multi-dict. For example: `request.headers['content-type']` -### Query Parameters +#### Query Parameters Headers are exposed as an immutable multi-dict. For example: `request.query_params['abc']` -### Body +#### Body There are two interfaces for returning the body of the request: @@ -162,6 +168,8 @@ The request body as bytes: `await request.body()` The request body, parsed as JSON: `await request.json()` +— âï¸ —
+ ## Test Client The test client allows you to make requests against your ASGI application, @@ -186,6 +194,8 @@ def test_app(): assert response.status_code == 200 ``` +— âï¸ —
+ ## Decorators The `asgi_application` decorator turns an `async` function into an ASGI application. @@ -203,4 +213,4 @@ async def app(request): --- -API Star is BSD licensed code.
Designed & built in Brighton, England.
— âï¸ —
API Star is BSD licensed code.
Designed & built in Brighton, England.