Move user location code outside of GET handler for /<fingerprint>
Technically, all of the operations available via /<fingerprint> will access the user object in some fashion, so loading of the user object can be done outside of the GET if-block.
This commit is contained in:
parent
26a92162dc
commit
d3730aa6cd
|
@ -72,9 +72,9 @@ def register():
|
||||||
|
|
||||||
@app.route("/<fingerprint>", methods=["GET", "UPDATE", "DELETE"])
|
@app.route("/<fingerprint>", methods=["GET", "UPDATE", "DELETE"])
|
||||||
def render_data(fingerprint):
|
def render_data(fingerprint):
|
||||||
|
user = User.query.filter_by(fingerprint=fingerprint).first()
|
||||||
|
if not user: return abort(404)
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
user = User.query.filter_by(fingerprint=fingerprint).first()
|
|
||||||
if not user: return abort(404)
|
|
||||||
resp = make_response(user.data or b"", 200)
|
resp = make_response(user.data or b"", 200)
|
||||||
resp.headers["Content-Type"] = user.mime_type
|
resp.headers["Content-Type"] = user.mime_type
|
||||||
return resp
|
return resp
|
||||||
|
|
Loading…
Reference in New Issue