MCPcopy Create free account
hub / github.com/N4si/microservices-python-app / download

Function download

src/gateway-service/server.py:56–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54
55@server.route("/download", methods=["GET"])
56def download():
57 access, err = validate.token(request)
58
59 if err:
60 unauth_count.inc()
61 return err
62
63 access = json.loads(access)
64
65 if access["admin"]:
66 fid_string = request.args.get("fid")
67
68 if not fid_string:
69 return "fid is required", 400
70
71 try:
72 out = fs_mp3s.get(ObjectId(fid_string))
73 return send_file(out, download_name=f"{fid_string}.mp3")
74 except Exception as err:
75 print(err)
76 return "internal server error", 500
77
78 return "not authorized", 401
79
80
81if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected