Skip to content

Commit cc13ec5

Browse files
committed
Implement /capture route with fast api
1 parent 1fec276 commit cc13ec5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

main.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import io
12
from typing import Annotated
23

3-
from fastapi import FastAPI, File
4+
from fastapi import FastAPI, File, UploadFile
5+
6+
from sgf.process_image import process_image
47

58
app = FastAPI()
69

@@ -11,6 +14,11 @@ def health_check():
1114

1215

1316
@app.post('/capture/')
14-
def capture(image: Annotated[bytes, File()]):
15-
print(f'{len(image)=}')
16-
return {'status': 'success'}
17+
def capture(image: Annotated[UploadFile, File()]):
18+
output_file = io.StringIO()
19+
process_image(image.file, output_file)
20+
output_file.seek(0)
21+
return {
22+
'sgf': output_file.read(),
23+
'image_filename': image.filename,
24+
}

0 commit comments

Comments
 (0)