hysts's picture
hysts HF Staff
Add files
4c3aac8
Raw
History Blame Contribute Delete
523 Bytes
import time
from collections.abc import Generator
from fastapi.responses import HTMLResponse
from gradio import Server
demo = Server()
@demo.api()
def stream(message: str) -> Generator[str, None, None]:
full = ""
for word in ["Hello", " ", "world", "!"]:
full += word
yield full
time.sleep(0.1)
@demo.get("/", response_class=HTMLResponse)
async def homepage():
with open("client.html", encoding="utf-8") as f:
return f.read()
if __name__ == "__main__":
demo.launch()