freddyaboulton HF staff commited on
Commit
0780993
1 Parent(s): 9c98a4e
Files changed (3) hide show
  1. app.py +29 -0
  2. requirements.txt +1 -0
  3. static/lion.jpg +0 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastapi import FastAPI
3
+ from fastapi.staticfiles import StaticFiles
4
+ import uvicorn
5
+
6
+
7
+ app = FastAPI()
8
+
9
+ @app.on_event("startup")
10
+ def print_foo():
11
+ print("FOO!!!")
12
+
13
+ def dream(prompt):
14
+ return ["lion.jpg"] * 2, {}
15
+
16
+ block = gr.Blocks().queue()
17
+ with block:
18
+ prompt = gr.Text()
19
+ gallery = gr.Gallery().style(grid=[2], height="auto")
20
+ contains_nfsw = gr.JSON(visible=False)
21
+ btn = gr.Button("Generate")
22
+ btn.click(dream, inputs=prompt, outputs=[gallery, contains_nfsw])
23
+
24
+ gradio_app = gr.routes.App.create_app(block)
25
+
26
+ app = gr.mount_gradio_app(app, gradio_app, "localhost", "7869", "/gradio")
27
+ app.mount("/", StaticFiles(directory="static", html=True), name="static")
28
+
29
+ uvicorn.run(app, "0.0.0.0", port=7860)
requirements.txt ADDED
@@ -0,0 +1 @@
 
1
+ ./gradio-3.4b0-py3-none-any.whl
static/lion.jpg ADDED