reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Document method to add backend api routes

Open picklelo opened this issue 3 years ago β€’ 0 comments

Currently you can do something like this:

app = pc.App(state=MyState)

@app.api.get("/items/{item_id}")
async def api_test(item_id: int):
    return {"my_result": item_id}

app.compile()

We can introduce a new method to allow this to be possible:

async def api_test(item_id: int):
    return {"my_result": item_id}

app = pc.App(state=MyState)
app.api.add_api_route("/items/{item_id}", api_test)
app.compile()

EDIT: The above code already works, we just need to document it

picklelo avatar Jan 17 '23 23:01 picklelo