Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions gradio/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@
VERSION_FILE = pkg_resources.resource_filename("gradio", "version.txt")
with open(VERSION_FILE) as version_file:
VERSION = version_file.read()
GRADIO_STATIC_ROOT = "https://gradio.s3-us-west-2.amazonaws.com/{}/static/".format(
VERSION
)
GRADIO_BUILD_ROOT = "https://gradio.s3-us-west-2.amazonaws.com/{}/assets/".format(
VERSION
)


class ORJSONResponse(JSONResponse):
Expand Down Expand Up @@ -142,8 +136,11 @@ def main(request: Request, user: str = Depends(get_current_user)):
}

try:
template = (
"frontend/share.html" if app.blocks.share else "frontend/index.html"
)
return templates.TemplateResponse(
"frontend/index.html", {"request": request, "config": config}
template, {"request": request, "config": config}
)
except TemplateNotFound:
raise ValueError(
Expand All @@ -158,20 +155,14 @@ def get_config():

@app.get("/static/{path:path}")
def static_resource(path: str):
if app.blocks.share:
return RedirectResponse(GRADIO_STATIC_ROOT + path)
else:
static_file = safe_join(STATIC_PATH_LIB, path)
static_file = safe_join(STATIC_PATH_LIB, path)
if static_file is not None:
return FileResponse(static_file)
raise HTTPException(status_code=404, detail="Static file not found")

@app.get("/assets/{path:path}")
def build_resource(path: str):
if app.blocks.share:
return RedirectResponse(GRADIO_BUILD_ROOT + path)
else:
build_file = safe_join(BUILD_PATH_LIB, path)
build_file = safe_join(BUILD_PATH_LIB, path)
if build_file is not None:
return FileResponse(build_file)
raise HTTPException(status_code=404, detail="Build file not found")
Expand Down
3 changes: 3 additions & 0 deletions scripts/upload_to_pypi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ else
pnpm build
cd ..
aws s3 cp gradio/templates/frontend s3://gradio/$new_version/ --recursive # requires aws cli (contact maintainers for credentials)
cp gradio/templates/frontend/index.html gradio/templates/frontend/share.html
assets_link="https://gradio.s3-us-west-2.amazonaws.com/$new_version/assets"
sed -i -e "s#\./assets#${assets_link}#g" gradio/templates/frontend/share.html
fi
rm -r dist/*
rm -r build/*
Expand Down