Kastg commited on
Commit
f984e57
·
verified ·
1 Parent(s): 7d4226e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -4,7 +4,6 @@ from pydantic import BaseModel
4
  import shutil
5
  import os
6
  import json
7
- import gradio as gr
8
 
9
  app = FastAPI(docs_url=None, redoc_url=None)
10
 
@@ -25,7 +24,7 @@ class ImageInfo(BaseModel):
25
  name: str
26
 
27
 
28
- @app.post("/upload/")
29
  async def upload_image(url: str, file: UploadFile = File(...)):
30
  allowed_formats = [".png", ".jpg"]
31
  file_format = os.path.splitext(file.filename)[1]
@@ -52,7 +51,7 @@ async def upload_image(url: str, file: UploadFile = File(...)):
52
  return JSONResponse(content={"message": "File uploaded successfully"})
53
 
54
 
55
- @app.get("/get-all-images/")
56
  async def get_all_images(password: str, from_folder: str):
57
  if password != "Kastg@123":
58
  raise HTTPException(status_code=401, detail="Unauthorized")
@@ -65,7 +64,7 @@ async def get_all_images(password: str, from_folder: str):
65
  return JSONResponse(content={"images": images})
66
 
67
 
68
- @app.delete("/delete-image/")
69
  async def delete_image(image_name: str, password: str):
70
  if password != "Kastg@123":
71
  raise HTTPException(status_code=401, detail="Unauthorized")
@@ -78,9 +77,5 @@ async def delete_image(image_name: str, password: str):
78
  available_images.pop(image_name, None)
79
  return JSONResponse(content={"message": "Image deleted successfully"})
80
 
81
- def greet(name):
82
- return "Hello " + name + "!"
83
-
84
- demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
85
-
86
- demo.launch(share=True)
 
4
  import shutil
5
  import os
6
  import json
 
7
 
8
  app = FastAPI(docs_url=None, redoc_url=None)
9
 
 
24
  name: str
25
 
26
 
27
+ @app.post("/upload")
28
  async def upload_image(url: str, file: UploadFile = File(...)):
29
  allowed_formats = [".png", ".jpg"]
30
  file_format = os.path.splitext(file.filename)[1]
 
51
  return JSONResponse(content={"message": "File uploaded successfully"})
52
 
53
 
54
+ @app.get("/get-all-images")
55
  async def get_all_images(password: str, from_folder: str):
56
  if password != "Kastg@123":
57
  raise HTTPException(status_code=401, detail="Unauthorized")
 
64
  return JSONResponse(content={"images": images})
65
 
66
 
67
+ @app.delete("/delete-image")
68
  async def delete_image(image_name: str, password: str):
69
  if password != "Kastg@123":
70
  raise HTTPException(status_code=401, detail="Unauthorized")
 
77
  available_images.pop(image_name, None)
78
  return JSONResponse(content={"message": "Image deleted successfully"})
79
 
80
+ if __name__ == "__main__":
81
+ app.run(host="0.0.0.0", port=7860, debug=True)