Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • F FastAPI
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Sitemule
  • Public
  • workshops
  • open source on IBM i
  • FastAPI
  • Wiki
  • Part 2b. Organise my first service

Part 2b. Organise my first service · Changes

Page history
Update Part 2b. Organise my first service authored Oct 30, 2021 by Jens Melgard Churchill's avatar Jens Melgard Churchill
Hide whitespace changes
Inline Side-by-side
Part-2b.-Organise-my-first-service.md
View page @ 65ea8bfb
......@@ -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
Clone repository
  • Part 1a. My first service
  • Part 1b. Testing my first service
  • Part 2a. Extending my first service
  • Part 2b. Organise my first service
  • Part 3a. Review my first service
  • Part 3b. Connecting my first service
  • Home