import gradio as gr from fastapi import FastAPI from fastapi.staticfiles import StaticFiles import uvicorn app = FastAPI() @app.on_event("startup") def print_foo(): print("FOO!!!") def dream(prompt): return "hello world!" block = gr.Blocks().queue() with block: prompt = gr.Text() gallery = gr.Text() btn = gr.Button("Generate") btn.click(dream, inputs=prompt, outputs=[gallery]) app = gr.mount_gradio_app(app, block, "/") app.mount("/img", StaticFiles(directory="images", html=True), name="images") uvicorn.run(app, host="0.0.0.0", port=7860)