| 246 | @app.route("/get_asset/<int:id>") |
| 247 | @app.route("/repos/<org>/<repo>/releases/assets/<int:id>") |
| 248 | async def get_asset(id, org=None, repo=None): |
| 249 | try: |
| 250 | asset = Asset._ASSETS[id] |
| 251 | except IndexError: |
| 252 | quart.abort( |
| 253 | 404, response=quart.jsonify({"message": "Not Found", "status": "404"}) |
| 254 | ) |
| 255 | |
| 256 | if "application/octet-stream" in request.accept_mimetypes: |
| 257 | if asset.contents is None: |
| 258 | print( |
| 259 | f"USAGE ERROR: Received request for contents of {asset.filename=} which was not stored" |
| 260 | ) |
| 261 | return "Did not store contents", 410 |
| 262 | return asset.contents |
| 263 | else: |
| 264 | return asset.render() |
| 265 | |
| 266 | |
| 267 | # Generic upload function, useful for testing clients in isolation |