-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to set custom creation date everywhere
- Loading branch information
1 parent
0091ac2
commit 58b39ed
Showing
4 changed files
with
26 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from typing import TYPE_CHECKING, List | ||
from typing import TYPE_CHECKING, List, Optional | ||
|
||
from fastapi import APIRouter, File, Request, UploadFile | ||
from fastapi import APIRouter, File, Query, Request, UploadFile | ||
|
||
if TYPE_CHECKING: | ||
from ..detector_node import DetectorNode | ||
|
@@ -9,13 +9,21 @@ | |
|
||
|
||
@router.post("/upload") | ||
async def upload_image(request: Request, files: List[UploadFile] = File(...)): | ||
async def upload_image(request: Request, | ||
files: List[UploadFile] = File(...), | ||
source: Optional[str] = Query(None, description='Source of the image'), | ||
creation_date: Optional[str] = Query(None, description='Creation date of the image')): | ||
""" | ||
Upload an image or multiple images to the learning loop. | ||
The image source and the image creation date are optional query parameters. | ||
Images are automatically tagged with 'picked_by_system'. | ||
Example Usage | ||
curl -X POST -F '[email protected]' "http://localhost:/upload" | ||
curl -X POST -F '[email protected]' "http://localhost:/upload?source=test&creation_date=2024-01-01T00:00:00" | ||
""" | ||
raw_files = [await file.read() for file in files] | ||
node: DetectorNode = request.app | ||
await node.upload_images(raw_files) | ||
await node.upload_images(raw_files, source, creation_date) | ||
return 200, "OK" |