swap if/else for case statement
This commit is contained in:
parent
26f2b4f4f2
commit
897f577706
9
app.py
9
app.py
|
@ -16,15 +16,16 @@ WEBSITE_DIRS = [name for name in os.listdir(ROOT_DIR) if not name.startswith('.'
|
|||
# Site choosing logic
|
||||
def current_website_dir():
|
||||
session.pop('website_dir', None)
|
||||
if session['requests'] % 5 == 0:
|
||||
match session['requests']:
|
||||
case 5:
|
||||
session['website_dir'] = (os.path.join(ROOT_DIR, 'Marvel'))
|
||||
elif session['requests'] % 6 == 0:
|
||||
case 6:
|
||||
session['website_dir'] = (os.path.join(ROOT_DIR, 'Escape'))
|
||||
session.pop('requests', None)
|
||||
else:
|
||||
case _:
|
||||
try:
|
||||
WEBSITE_DIRS.remove(os.path.join(ROOT_DIR, 'Marvel'))
|
||||
WEBSITE_DIRS.remove(os.path.join(ROOT_DIR, 'Escape'))
|
||||
WEBSITE_DIRS.remove(os.path.join(ROOT_DIR, 'Marvel'))
|
||||
except (ValueError, IndexError) as e:
|
||||
pass
|
||||
session['website_dir'] = random.choice(WEBSITE_DIRS)
|
||||
|
|
Loading…
Reference in New Issue