SolaraS
Solara2y ago
3 replies
Rob02

Multiple different solara apps under Fastapi endpoints?

Hi, I can follow the explanation from the docs to integrate one solara app into an existing FastAPI application
https://solara.dev/docs/deploying/self-hosted

from fastapi import FastAPI
import solara.server.fastapi

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


app.mount("/solara/", app=solara.server.fastapi.app)

and
SOLARA_APP=sol.py uvicorn solara_on_fastapi:app


As this is using one environment variable, i am not sure how to extend this to have two independent solara apps on two different endpoints.eg.


from fastapi import FastAPI
import solara.server.fastapi

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}

# with sol1.py
app.mount("/solara1/", app=solara.server.fastapi.app)
# with sol2.py
app.mount("/solara2/", app=solara.server.fastapi.app)

and
SOLARA_APP1=sol1.py SOLARA_APP2=sol2.py uvicorn solara_on_fastapi:app


Is there an easy way to do this, maybe by not using a single env variable?
Thanks a lot.
Preview image
Was this page helpful?