Percy3822 commited on
Commit
f2d2827
·
verified ·
1 Parent(s): b80e30a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -1,17 +1,17 @@
1
- import gradio as gr
2
- import mss
3
  from PIL import Image
4
- import numpy as np
5
  import io
6
 
7
- def capture_screen():
8
- with mss.mss() as sct:
9
- monitor = sct.monitors[1] # full screen
10
- screenshot = sct.grab(monitor)
11
- img = Image.frombytes("RGB", screenshot.size, screenshot.rgb)
12
- return img
13
 
14
- demo = gr.Interface(fn=capture_screen, inputs=[], outputs="image")
15
-
16
- if __name__ == "__main__":
17
- demo.launch()
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, UploadFile, File
2
+ from fastapi.responses import JSONResponse
3
  from PIL import Image
 
4
  import io
5
 
6
+ app = FastAPI()
 
 
 
 
 
7
 
8
+ @app.post("/upload")
9
+ async def upload(file: UploadFile = File(...)):
10
+ try:
11
+ contents = await file.read()
12
+ image = Image.open(io.BytesIO(contents))
13
+ # You can run your AI analysis here
14
+ print("Screenshot received")
15
+ return JSONResponse({"status": "success"})
16
+ except Exception as e:
17
+ return JSONResponse({"status": "error", "details": str(e)})