summaryrefslogtreecommitdiffstats
path: root/clover/controller/control/api/file_upload.py
blob: a479c300efa678d3212f29d335f096573c5b9d3e (plain)
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
# Copyright (c) Authors of Clover
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0

from flask import Blueprint, request, Response
import redis
import logging

file_upload = Blueprint('file_upload', __name__)

HOST_IP = 'redis'


@file_upload.route("/upload", methods=['GET', 'POST'])
def upload_meta():
    try:
        content = request.form
        r = redis.StrictRedis(host=HOST_IP, port=6379, db=0)
        response = content.get('upload.name')
        r.set('upload_meta', response)
    except Exception as e:
        logging.debug(e)
        r.set('upload_meta', "failure")
        return Response('Unable to write file metadata to redis', status=400)
    return response