()
| 54 | |
| 55 | @server.route("/download", methods=["GET"]) |
| 56 | def 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 | |
| 81 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected