diff --git a/drama/routes/posts.py b/drama/routes/posts.py index be124ff36..5655b7ad6 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -25,24 +25,25 @@ with open("snappy.txt", "r") as f: @app.route("/resize") def resize(): u = g.db.query(User).filter(User.profileurl != None, User.resized != True).first() - print(u.username) - print(f"1 {u.profileurl}") - x = requests.get(u.profileurl) + if u: + print(u.username) + print(f"1 {u.profileurl}") + x = requests.get(u.profileurl) - with open("resizing", "wb") as file: - for chunk in x.iter_content(1024): - file.write(chunk) + with open("resizing", "wb") as file: + for chunk in x.iter_content(1024): + file.write(chunk) - image = upload_from_file("resizing", "resizing", (100, 100)) - if image == None: - send_notification(1, u, "fail!") - u.resized = True - g.db.add(u) - else: - u.profileurl = image - u.resized = True - g.db.add(u) - print(f"2 {u.profileurl}") + image = upload_from_file("resizing", "resizing", (100, 100)) + if image == None: + send_notification(1, u, "fail!") + u.resized = True + g.db.add(u) + else: + u.profileurl = image + u.resized = True + g.db.add(u) + print(f"2 {u.profileurl}") @app.route("/banaward/post/") @auth_required