S
Solara6mo ago
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)
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
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)
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
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.
3 Replies
MaartenBreddels
MaartenBreddels6mo ago
this is not currently something we support although in some parts of the code we have taken this into account, it is not something we plan to support on the short term (see also https://github.com/widgetti/solara/issues/27 ) Can I ask why you would need/want this? I think it should also be easy to have multiple "subpages" instead of separate apps
Monty Python
Monty Python6mo ago
samiit
<:issue_closed_completed:979047130847117343> [widgetti/solara] Serving App via FastAPI
Hi everyone, I would love to have some documentation hints at how to serve a wonderful SOLARA app using FastAPI. In the example shown here, I don't know how to specify the python file name that contains the app. I guess the first argument of app.mount, i.e., /solara is the directory containing the python file containing the app. Thanks, Sam
Created
Rob02
Rob026mo ago
I hadnt seen this, thanks. I just want to be able to quickly test different solara apps (or versions of the same) on different endpoints. I think one could put them under pages/ in a multipage app and then access the pages directly. I.e. https://solara.dev/apps/multipage/page1 and https://solara.dev/apps/multipage/page2 but this will give someone access to all pages.
Want results from more Discord servers?
Add your server