Skip to content

Deploy Single API from multiple APIs as a microservice #5397

@jayudhandha

Description

@jayudhandha

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

# segment/main.py

from fastapi import FastAPI

app = FastAPI()
    
@app.get("/")
def read_root():
    return {"Hello": "Segment"}

# campaign/main.py
from fastapi import FastAPI

app = FastAPI()
    
@app.get("/")
def read_root():
    return {"Hello": "Campaign"}

Description

In below link I saw that we can define routes when we have multiple APIs in Fast API.
https://fastapi.tiangolo.com/tutorial/bigger-applications/

Now my question is, How can i deploy single API from whole project. I want to keep logger, exception & utility classes common and don't want to re-deploy them.

Below if my folder structure. Here in api folder, I want to deploy segment and campaign APIs independently.

FastAPI-Folder Structure

I'm new in FastAPI so forgive me in advance if i asked silly question :D

Operating System

Windows

Operating System Details

No response

FastAPI Version

0.79.0

Python Version

3.8

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions