-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replaced msgspec with pydantic and blacksheep with quart (#43)
* replaced msgspec with pydantic and blacksheep with quart * updated type from BaseException -> Exception * Revert "updated type from BaseException -> Exception" This reverts commit d97c1b6. * added arbitrary_types_allowed=True to pydantic model config * updated test server response * removed arg
- Loading branch information
Showing
5 changed files
with
329 additions
and
197 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
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
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 |
---|---|---|
@@ -1,21 +1,24 @@ | ||
from blacksheep import Application, Request, Response, get, json, post | ||
from quart import Quart, jsonify, Response, Request | ||
|
||
app = Application() | ||
app = Quart(__name__) | ||
|
||
|
||
@get("/") | ||
@app.get("/") | ||
async def index() -> Response: | ||
return json({"message": "Hello, world!"}) | ||
return jsonify({"message": "Hello, world!"}) | ||
|
||
|
||
@post("/foo") | ||
async def post_foo(request: Request) -> Response: | ||
data = await request.json() | ||
resp: Response = json(data) | ||
resp.add_header(b"X-Test", b"Test") | ||
@app.post("/foo") | ||
async def post_foo() -> Response: | ||
resp = jsonify({"foo": "bar"}) | ||
resp.headers["X-Test"] = "Test" | ||
return resp | ||
|
||
|
||
@get("/exception") | ||
@app.get("/exception") | ||
async def mock_exception() -> Response: | ||
raise Exception("Mock exception") | ||
|
||
|
||
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
Oops, something went wrong.