We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cf8f141 commit 6a85b4bCopy full SHA for 6a85b4b
examples/fastapi_app.py
@@ -0,0 +1,30 @@
1
+from __future__ import annotations
2
+import typing
3
+
4
+from microbootstrap.bootstrappers.fastapi import FastApiBootstrapper
5
+from microbootstrap.granian_server import create_granian_server
6
+from microbootstrap.settings import FastApiSettings
7
8
9
+if typing.TYPE_CHECKING:
10
+ import fastapi
11
12
13
+class Settings(FastApiSettings): ...
14
15
16
+settings = Settings()
17
18
19
+def create_app() -> fastapi.FastAPI:
20
+ app = FastApiBootstrapper(settings).bootstrap()
21
22
+ @app.get("/")
23
+ async def hello_world() -> dict[str, str]:
24
+ return {"hello": "world"}
25
26
+ return app
27
28
29
+if __name__ == "__main__":
30
+ create_granian_server("examples.fastapi_app:create_app", settings, factory=True).serve()
0 commit comments