-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathprocessImage.py
More file actions
32 lines (28 loc) · 1.21 KB
/
processImage.py
File metadata and controls
32 lines (28 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from . import api
from app.utils import checkFile, processFile
from flask_restx import Resource, reqparse
from werkzeug.datastructures import FileStorage
@api.route("/processImage")
class ProcessImage(Resource):
def post(self):
parser = reqparse.RequestParser(bundle_errors=True, trim=True)
# From POST body
parser.add_argument("octavescale", type=float, location="form", required=True)
parser.add_argument("iterations", type=int, location="form", required=True)
parser.add_argument("octaves", type=int, location="form", required=True)
parser.add_argument("jitter", type=int, location="form", required=True)
parser.add_argument("stepsize", type=float, location="form", required=True)
parser.add_argument("layer", location="form", required=True)
# From file uploads
parser.add_argument(
"file",
type=FileStorage,
required=True,
location="files",
help="You did not selected an image to process.",
)
args = parser.parse_args(strict=True)
# sanity check
isFileValid = checkFile(args["file"])
if isFileValid["OK"]:
return processFile(args)