Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyaboulton committed Mar 6, 2024
1 parent e5ee763 commit 5262a4a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/python/gradio_client/documentation.py
Expand Up @@ -57,6 +57,7 @@ def extract_instance_attr_doc(cls, attr):
("gradio.route", "routes"),
("gradio.theme", "themes"),
("gradio_client.", "py-client"),
("gradio.data_classes", "helpers"),
]


Expand Down
28 changes: 28 additions & 0 deletions gradio/data_classes.py
Expand Up @@ -10,6 +10,7 @@
from typing import TYPE_CHECKING, Any, List, Optional, Union

from fastapi import Request
from gradio_client.documentation import document
from gradio_client.utils import traverse

from . import wasm_utils
Expand Down Expand Up @@ -212,7 +213,34 @@ def __iter__(self):
return iter(self.root)


@document()
class StaticFiles:
"""
Static files to be served by the gradio app.
Static files are not moved to the gradio cache and are served directly from the file system.
This class is useful when you want to serve files that you know will not be modified during the lifetime of the gradio app (like examples).
By using StaticFilesm your app will launch faster and it will consume less disk space.
Example:
import gradio as gr
# Paths can be a list of strings or pathlib.Path objects
# corresponding to filenames or directories.
gr.StaticFiles(paths=["test/test_files/"])
# The example files and the default value of the input
# will not be copied to the gradio cache and will be served directly.
demo = gr.Interface(
lambda s: s.rotate(45),
gr.Image(value="test/test_files/cheetah1.jpg", type="pil"),
gr.Image(),
examples=["test/test_files/bus.png"],
)
demo.launch()
"""

all_paths = []

def __init__(self, paths: list[str | pathlib.Path]) -> None:
Expand Down

0 comments on commit 5262a4a

Please sign in to comment.