-
Notifications
You must be signed in to change notification settings - Fork 2.9k
load theme.css
relatively instead of from config.root
#11165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
load theme.css
relatively instead of from config.root
#11165
Conversation
Ran into this today, looking forward to this being released. |
I believe the reason we load the theme.css (and some other content) from config.root rather than relatively, is in the case of gradio app embeds.
And mirrorsite would load the app from |
🪼 branch checks and previews
|
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
@aliabid94 thanks for highlighting this, would you be able to point me to or create a sample app with this method of app embedding? I'd be happy to test this change with that configuration!
@kuhnroyal happy to make this change too if this approach ends up working out for the app embed method @aliabid94 described! This change resolves the theme.css loading issue I'm seeing when the gradio app is embedded via an iframe in a proxied environment. I have a standalone sample app setup in #11164, but in my iframe setup, the same issue occurs. It would be great to also confirm this wouldn't break the case you're describing. |
Sorry for the late reply @sharon-wang ! If you run the following demo below, it works on main but does not work on this branch (after you rebuild the frontend). This demo uses your local gradio build for the frontend to locally embed the gradio app at https://opensound-solospeech.hf.space from fastapi import FastAPI
import uvicorn
from fastapi.responses import HTMLResponse
app = FastAPI()
@app.get("/gradio/{path:path}")
def gradio_lib(path):
import importlib.resources
BUILD_PATH_LIB = importlib.resources.files("gradio").joinpath("templates/frontend/").as_posix()
return HTMLResponse(
open(f"{BUILD_PATH_LIB}/{path}").read(),
media_type="text/javascript" if path.endswith(".js") else "text/css",
)
@app.get("/")
def main():
return HTMLResponse(
"""
<html>
<head>
<title>Gradio Embed</title>
</head>
<body>
<script type="module" src="/gradio/gradio.js"></script>
<gradio-app src="https://opensound-solospeech.hf.space"></gradio-app>
</body>
</html>
"""
)
if __name__ == "__main__":
uvicorn.run(app=app,) |
This should be fixed via #11387, so I'll close this PR for now |
Description
To address #11164, here's a proposal to load
theme.css
relatively instead of fromconfig.root
, so that thelink
href
is the expected value when the gradio server is accessed via a proxy server.Closes: #11164
Current
Other resources loaded in the
head
With Proposed Change