@app.route("/product/<tiid>/file", methods=['GET', 'POST'])
def product_file(tiid):

    if request.method == "GET":
        try:
            product = get_product(tiid)
            if not product:
                return abort_json(404, "product not found")

            if product.has_file:
                my_file = product.get_file()
                resp = make_response(my_file, 200)
                return resp
            else:
                abort_json(404, "This product exists, but has no file.")

        except __HOLE__:
            abort_json(404, "That product doesn't exist.")
        except S3ResponseError:
            abort_json(404, "This product exists, but has no file.")


    elif request.method == "POST":
        current_user_must_own_tiid(tiid)
        file_to_upload = request.files['file'].stream
        product = get_product(tiid)      
        resp = upload_file_and_commit(product, file_to_upload, db)

        return json_resp_from_thing(resp)
dataset/ETHPy150Open Impactstory/total-impact-webapp/totalimpactwebapp/views.py/product_file