コード例 #1
0
ファイル: views.py プロジェクト: ElectroBaer/MasterProject
def recording_data(recording):
    print('User: '******'start'))
    end_point = float(request.args.get('end'))

    series = plot_data.get_series(start_point, end_point)

    # series.append(plot_data.annotations)
    # series.append(plot_data.time_stamp_series)

    # print(time_stamp_series)
    return jsonify(series)
コード例 #2
0
ファイル: views.py プロジェクト: ElectroBaer/MasterProject
def recording_description(recording):
    print('User: '******'GET':
        description_file = open(description_file_path, 'r')
        return jsonify({'description': description_file.read()})
    elif request.method == 'POST':
        print('Get new description')
        new_description = request.form.get('description')
        description_file = open(description_file_path, 'w')
        description_file.write(new_description)
        description_file.close()

    return redirect(url_for('views.get_recording', recording=recording))
コード例 #3
0
ファイル: views.py プロジェクト: ElectroBaer/MasterProject
def new_recording():
    # secret_token = request.args.get('token')
    # if secret_token is None or secret_token != config.client_secret:
    #     return jsonify({'status': 'not authenticated'})

    print('User: '******'GET':
        new_uuid = uuid.uuid4()
        print('Deliver new uuid:', new_uuid)
        return jsonify({'status': 'success', 'uuid': new_uuid})
    elif request.method == 'POST':
        print('Get new records')
        request_uuid = request.args.get('uuid')
        print('Id: ', request_uuid)
        if request_uuid is None or request_uuid == '':
            print('No uuid')
            return jsonify({'status': 'error, now uuid'})
        if 'file' not in request.files:
            print('No file part')
            return jsonify({'status': 'error, now file'})
        file = request.files['file']
        if file.filename == '':
            print('No selected file')
            return jsonify({'status': 'error, now selected file'})
        if file and is_allowed_file(file.filename):
            filename = secure_filename(file.filename)
            if config.rename_mic_files and 'mic' in filename and '.zip' in filename:
                numbering = filename.split('_')[-1]
                filename = generate_random_string(16) + '_' + numbering
            upload_path = os.path.join(RECORDINGS_FOLDER, request_uuid)
            if not os.path.isdir(upload_path):
                os.mkdir(upload_path)
                description_file = open(os.path.join(upload_path, "README.md"),
                                        'x')

            file.save(os.path.join(upload_path, filename))
            add_file_to_zip(filename, upload_path, request_uuid)
            return jsonify({'status': 'success, uploaded ' + file.filename})

        return jsonify({'status': 'success'})
    return jsonify({'status': 'error'})