Spaces:
Sleeping
Sleeping
Commit
•
def8982
1
Parent(s):
9a5dd3c
Add stuff
Browse files- app.py +29 -0
- requirements.txt +1 -0
- 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 ["static/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 |
+
assert False
|
29 |
+
uvicorn.run(app, host='0.0.0.0', port=7860)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
https://gradio-builds.s3.amazonaws.com/7937027da4c92a062de25f97678a5e4c83e9bb3f/gradio-3.3.1-py3-none-any.whl
|
static/lion.jpg
ADDED