Spaces:
Runtime error
Runtime error
update
Browse files- app.py +2 -32
- main.app +34 -0
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -1,34 +1,4 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
-
|
| 4 |
-
from PIL import Image
|
| 5 |
-
import base64
|
| 6 |
-
|
| 7 |
-
app = FastAPI()
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
@app.get("/")
|
| 11 |
-
async def root():
|
| 12 |
-
images = []
|
| 13 |
-
|
| 14 |
-
with open('image1.jpg', 'rb') as open_file:
|
| 15 |
-
byte_content = open_file.read()
|
| 16 |
-
base64_bytes = base64.b64encode(byte_content)
|
| 17 |
-
base64_string = base64_bytes.decode('utf-8')
|
| 18 |
-
images.append(base64_string)
|
| 19 |
-
|
| 20 |
-
with open('image2.jpg', 'rb') as open_file:
|
| 21 |
-
byte_content = open_file.read()
|
| 22 |
-
base64_bytes = base64.b64encode(byte_content)
|
| 23 |
-
base64_string = base64_bytes.decode('utf-8')
|
| 24 |
-
images.append(base64_string)
|
| 25 |
-
|
| 26 |
-
#image_path='lion.jpg'
|
| 27 |
-
#pilim = Image.open(image_path)
|
| 28 |
-
#pilimrot = pilim.rotate(45)
|
| 29 |
-
return {"data": images}
|
| 30 |
-
|
| 31 |
-
@app.get("/items/{item_id}")
|
| 32 |
-
async def read_item(item_id):
|
| 33 |
-
return {"item_id": item_id}
|
| 34 |
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
|
| 3 |
+
subprocess.run("uvicorn modules.app:app --host 0.0.0.0 --port 7860", shell=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
main.app
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# main.py
|
| 2 |
+
|
| 3 |
+
from fastapi import FastAPI
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import base64
|
| 6 |
+
|
| 7 |
+
app = FastAPI()
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@app.get("/")
|
| 11 |
+
async def root():
|
| 12 |
+
images = []
|
| 13 |
+
|
| 14 |
+
with open('image1.jpg', 'rb') as open_file:
|
| 15 |
+
byte_content = open_file.read()
|
| 16 |
+
base64_bytes = base64.b64encode(byte_content)
|
| 17 |
+
base64_string = base64_bytes.decode('utf-8')
|
| 18 |
+
images.append(base64_string)
|
| 19 |
+
|
| 20 |
+
with open('image2.jpg', 'rb') as open_file:
|
| 21 |
+
byte_content = open_file.read()
|
| 22 |
+
base64_bytes = base64.b64encode(byte_content)
|
| 23 |
+
base64_string = base64_bytes.decode('utf-8')
|
| 24 |
+
images.append(base64_string)
|
| 25 |
+
|
| 26 |
+
#image_path='lion.jpg'
|
| 27 |
+
#pilim = Image.open(image_path)
|
| 28 |
+
#pilimrot = pilim.rotate(45)
|
| 29 |
+
return {"data": images}
|
| 30 |
+
|
| 31 |
+
@app.get("/items/{item_id}")
|
| 32 |
+
async def read_item(item_id):
|
| 33 |
+
return {"item_id": item_id}
|
| 34 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
subprocess
|