| import time | |
| from collections.abc import Generator | |
| from fastapi.responses import HTMLResponse | |
| from gradio import Server | |
| demo = Server() | |
| def stream(message: str) -> Generator[str, None, None]: | |
| full = "" | |
| for word in ["Hello", " ", "world", "!"]: | |
| full += word | |
| yield full | |
| time.sleep(0.1) | |
| async def homepage(): | |
| with open("client.html", encoding="utf-8") as f: | |
| return f.read() | |
| if __name__ == "__main__": | |
| demo.launch() | |