-
Notifications
You must be signed in to change notification settings - Fork 189
Open
Description
Hi @kantancoding ,
I followed your Youtube tutorial. I experienced some errors during implementation in my local system. I tried in both Windows and Ubuntu. I got more parts working in Windows. In Ubuntu, I can move forward through MySQL Error.
Now my problem is I am not able to download the converted mp3 file. Everything else works fine. The upload part works fine. The Rabbit MQ console page shows the message flow correctly in overview page. But when I try to download the converted file, I got error in gateway pod. The error is:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 883, in full_dispatch_request
return self.finalize_request(rv)
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 902, in finalize_request
response = self.make_response(rv)
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1174, in make_response
raise TypeError(
TypeError: The view function for 'download' did not return a valid response. The function either returned None or ended without
10.244.0.35 - - [13/Oct/2024 17:26:52] "GET /download?fid=670c012c7b8bed687d11e620 HTTP/1.1" 500 -
The gateway/server.py file is:
import os, gridfs, pika, json
from flask import Flask, request, send_file
from flask_pymongo import PyMongo
from auth import validate
from auth_svc import access
from storage import util
from bson.objectid import ObjectId
server = Flask(__name__)
mongo_video = PyMongo(server, uri="mongodb://host.minikube.internal:27017/videos")
mongo_mp3 = PyMongo(server, uri="mongodb://host.minikube.internal:27017/mp3s")
fs_videos = gridfs.GridFS(mongo_video.db)
fs_mp3s = gridfs.GridFS(mongo_mp3.db)
connection = pika.BlockingConnection(pika.ConnectionParameters("rabbitmq"))
channel = connection.channel()
@server.route("/login", methods=["POST"])
def login():
token, err = access.login(request)
if not err:
return token
else:
return err
@server.route("/upload", methods=["POST"])
def upload():
access, err = validate.token(request)
if err:
return err
access = json.loads(access)
if access["admin"]:
if len(request.files) > 1 or len(request.files) < 1:
return "exactly 1 file required", 400
for _, f in request.files.items():
err = util.upload(f, fs_videos, channel, access)
if err:
return err
return "success!", 200
else:
return "not authorized", 401
@server.route("/download", methods=["GET"])
def download():
access, err = validate.token(request)
if err:
return err
access = json.loads(access)
if access["admin"]:
fid_string = request.args.get("fid")
if not fid_string:
return "fid is required", 400
try:
out = fs_mp3s.get(ObjectId(fid_string))
return send_file(out, download_name=f"{fid_string}.mp3")
except Exception as err:
print(err)
return "internal server error", 500
return "not authorized", 401
if __name__ == "__main__":
server.run(host="0.0.0.0", port=8080)
What will be the problem ? Can you please explain this and help me to solve the problem?
Metadata
Metadata
Assignees
Labels
No labels