Skip to content

Can we create multiple endpoits for the list of endpoints.. #1833

@Pechi77

Description

@Pechi77

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.
  • After submitting this, I commit to:
    • Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
    • Or, I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
    • Implement a Pull Request for a confirmed bug.

Environment

  • OS: [e.g. Linux / Windows / macOS]: windows

  • FastAPI Version [e.g. 0.3.0]: 0.44.0

  • Python version: 3.7.5

Lets say I have a list of endpoints for my app:

endpoints = ["/endpoint1", "/endpoint2" , "/endpoint2" ]

and need to create multiple endpoints dynamically like below...

@app.get("/endpoint1")
async def func1():
    data = {
        "status": 200, 
        "endpoint_no" : "endpoint1"
        }

    return data

@app.get("/endpoint2")
async def func2():
    data = {
        "status": 200, 
        "endpoint_no" : "endpoint2"
        }

    return data

@app.get("/endpoint3")
async def func3():
    data = {
        "status": 200, 
        "endpoint_no" : "endpoint3"
        }

    return data


@app.get("/endpoint4")
async def func4():
    data = {
        "status": 200, 
        "endpoint_no" : "endpoint4"
        }

    return data


@app.get("/endpoint5")
async def func5():
    data = {
        "status": 200, 
        "endpoint_no" : "endpoint5"
        }

    return data


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