question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deploy Single API from multiple APIs as a microservice

See original GitHub issue

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 😄

Operating System

Windows

Operating System Details

No response

FastAPI Version

0.79.0

Python Version

3.8

Additional Context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
csrgxtucommented, Sep 20, 2022

@jayudhandha so you want to deploy campaign and segment defferently, ie start campaign on server-a and segment on server-b, right?

1, copy code to server-* 2, if you want to start campaign just run following:

uvicorn api.campaign:app 

3, if you want to start segment just run following:

uvicorn api.segment:app
0reactions
jayudhandhacommented, Nov 21, 2022

Closing this issue as I’ve used Router for our requirements.

Thanks, Jayesh

Read more comments on GitHub >

github_iconTop Results From Across the Web

Architecting multiple microservices behind a single domain ...
Implement a process to ensure each customer's API Gateway API key is the same across accounts for a smooth customer experience. API Gateway ......
Read more >
java - Deploy multiple APIs under one customized domain ...
I am trying to deploy microservices application using amazon web services products.My application wouldn't be really big, ...
Read more >
The API gateway pattern versus the direct client-to ...
Understand the differences and the uses of the API gateway pattern and the direct client-to-microservice communication.
Read more >
API Microservices bundle multiple services as one ...
So I am going to be developing atleast 5-6 Res end points . ( all distinct and stateless ) Now I am debating...
Read more >
How to deploy multiple micro-services under one API domain ...
Learn how to use the same domain name for multiple Serverless services with API Gateway base path mappings.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found