예제 #1
0
파일: rest.py 프로젝트: Signez/dradis2
def list_studios():
    studio_serializer = JSONSerializer(Studio)
    query = Studio.query.limit(request.args.get('limit')).order_by(Studio.slug)

    squack()

    return jsonify(sanitize(studio_serializer.serialize(query)))
예제 #2
0
def upload_media():
    kind = request.args.get('kind')
    username = '******'  # FIXME: Add account support
    uploaded_file = request.files['file']

    if uploaded_file:
        filename = utilities.secure_filename(uploaded_file.filename)
        filename = decorate_filename(filename, kind, username)
        new_path = os.path.join(app.config['MEDIA_ROOT'], 'uploads', filename)
        uploaded_file.save(new_path)

        if not allowed_file(
                uploaded_file.filename) or not allowed_file_type(new_path):
            os.remove(new_path)
            return jsonify(error_message("not_allowed"))

        squack()

        return jsonify({
            "status":
            "done",
            "result":
            new_path.replace(app.config['MEDIA_ROOT'], app.config['MEDIA_URL'])
        })
    else:
        return jsonify(error_message("not_received_file"))
예제 #3
0
def list_studios():
    studio_serializer = JSONSerializer(Studio)
    query = Studio.query.limit(request.args.get('limit')).order_by(Studio.slug)

    squack()

    return jsonify(sanitize(studio_serializer.serialize(query)))
예제 #4
0
파일: upload.py 프로젝트: Signez/dradis2
def upload_media():
    kind = request.args.get("kind")
    username = "******"  # FIXME: Add account support
    uploaded_file = request.files["file"]

    if uploaded_file:
        filename = utilities.secure_filename(uploaded_file.filename)
        filename = decorate_filename(filename, kind, username)
        new_path = os.path.join(app.config["MEDIA_ROOT"], "uploads", filename)
        uploaded_file.save(new_path)

        if not allowed_file(uploaded_file.filename) or not allowed_file_type(new_path):
            os.remove(new_path)
            return jsonify(error_message("not_allowed"))

        squack()

        return jsonify(
            {"status": "done", "result": new_path.replace(app.config["MEDIA_ROOT"], app.config["MEDIA_URL"])}
        )
    else:
        return jsonify(error_message("not_received_file"))