... | ... | @@ -4,11 +4,9 @@ While FastAPI is brilliant at building API's, it is also able to build self-cont |
|
|
|
|
|
## Content + Style == Success
|
|
|
|
|
|
Usually, the frontpage of a site (index.html), doesn't return JSON data.
|
|
|
So lets change that first.
|
|
|
Usually, the frontpage of a site (index.html), doesn't return JSON data. So lets change that first.
|
|
|
|
|
|
Remove the function `read_root()` and its body, the `return {"Hello": "World"}`
|
|
|
Replace it with the following code
|
|
|
Remove the function `read_root()` and its body, the `return {"Hello": "World"}` Replace it with the following code
|
|
|
|
|
|
```python
|
|
|
@app.get("/")
|
... | ... | @@ -30,7 +28,10 @@ There are many response classes in FastAPI, and in this case we make use of its |
|
|
|
|
|
You know the drill, save `:w` and navigate to your services frontpage: [fastapi.ibmi.rocks](https://fastapi.ibmi.rocks)
|
|
|
|
|
|
![image](uploads/4da818bf309a484ecf29656ab0557159/image.png)
|
|
|
|
|
|
Success !
|
|
|
|
|
|
## Since we care about maintainability, lets do a bit of housework
|
|
|
|
|
|
First, API's can grow large containing many endpoints, having them all in one file is silly.
|
|
|
A bit of refactoring can go a long way, but |
|
|
\ No newline at end of file |
|
|
First, API's can grow large containing many endpoints, having them all in one file is silly. A bit of refactoring can go a long way, but |
|
|
\ No newline at end of file |