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)))
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"))
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"))