From f5127995094426df54a12c1cc127864e541abdac Mon Sep 17 00:00:00 2001 From: Andrei Date: Thu, 23 Jun 2022 18:05:31 +0500 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=D0=BE=D0=BF=D1=80=D0=BE=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 86c9757..467a0f6 100644 --- a/main.py +++ b/main.py @@ -144,7 +144,8 @@ def main_page(): post_quest = session.query(Quest).filter(Quest.id.in_([i.id_question for i in quest])).all() else: post_quest = [] - while len(post_quest) < days_reg: + max_quests = len(session.query(Quest).all()) + while len(post_quest) < days_reg and max_quests > len(post_quest): post_quest.append( session.query(Quest).filter(Quest.id.notin_([i.id for i in post_quest])).first()) ans = [] @@ -684,7 +685,8 @@ def diary(): post_quest = db_sess.query(Quest).filter(Quest.id.in_([i.id_question for i in quest])).all() else: post_quest = [] - while len(post_quest) < days_reg: + max_quests = len(db_sess.query(Quest).all()) + while len(post_quest) < days_reg and max_quests > len(post_quest): post_quest.append( db_sess.query(Quest).filter(Quest.id.notin_([i.id for i in post_quest])).first()) ans = [] @@ -699,7 +701,7 @@ def diary(): ans2 = {} for i in ans: ans2[i.id_question] = i - except Exception: + except Exception as e: ans2 = [] else: posts = None @@ -872,7 +874,8 @@ def about(): def main(): db_session.global_init("db/moona_data.db") try: - serve(app, host='0.0.0.0', port=5000) + app.run(host='0.0.0.0', port=5000) + # serve(app, host='0.0.0.0', port=5000) except Exception as error: logging.warning(f'{datetime.datetime.now()}:{error}') print(error)