Best practice to structure multiple module
See original GitHub issueWhen I sperate apis into multiple module, I find it hard to structure the code, currently I approach like this:
# app.py
from fastapi import FastAPI
app = FastAPI()
# api1.py
from app import app
@app.get('/test1')
...
# api2.py
from app import app
@app.get('/test2')
...
# main.py
from app import app
import api1
import api2
$ uvicorn main:app --lifespan on
...
Any suggestions?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Best practices for multi-module projects with Spring Boot
#1 Find a proper module structure · #2 Minimize dependencies · #3 Continuous improvement · #4 Gradle api vs implementation · #5 Use...
Read more >Angular modules: Best practices for structuring your app
In this tutorial, we'll show you how to structure your application into a series of smaller blocks, or modules, of functionality. We'll walk ......
Read more >Best Practices for Modular Application Design and Development
Building a modular app requires expertise and deep knowledge of coding principles. Here you'll find some best practices for modular app ...
Read more >Type safe, multi-module best practices with Navigation ...
As your app grows in size and complexity, following these best practices for using Navigation Compose will set you up for expanding your ......
Read more >Getting Started | Creating a Multi Module Project - Spring
This guide shows you how to create a multi-module project with Spring Boot. The project will have a library jar and a main...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
From the FastAPI project-generator codebase:
Right, you’d have to give it a name (e.g.
@router.get("/items", response_model=List[Item])
).You can mount multiple routers with the same prefix if, for example, you want to have multiple distinct resources with the same prefix and different non-slash-ending endpoints: