File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1
1
import io
2
+ from pathlib import Path
2
3
from typing import Annotated
3
4
4
- from fastapi import FastAPI , File , UploadFile
5
+ from fastapi import FastAPI , File , UploadFile , Form
5
6
7
+ import settings
6
8
from sgf .process_image import process_image
9
+ from tasks import process_image_task
7
10
8
11
app = FastAPI ()
9
12
@@ -22,3 +25,15 @@ def capture(image: Annotated[UploadFile, File()]):
22
25
'sgf' : output_file .read (),
23
26
'image_filename' : image .filename ,
24
27
}
28
+
29
+
30
+ @app .post ('/capture_async/' )
31
+ def capture_async (
32
+ image : Annotated [UploadFile , File ()],
33
+ fcm_registration_token : Annotated [str , Form ()]
34
+ ):
35
+ filename = Path (image .filename )
36
+ output_path = settings .IMAGES_DIR / filename
37
+ with output_path .open ("wb" ) as output_file :
38
+ output_file .write (image .file .read ())
39
+ process_image_task .delay (str (output_path .absolute ()), fcm_registration_token )
You can’t perform that action at this time.
0 commit comments