This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
uwu-me/uwume/lib/helpers.py

42 lines
1.3 KiB
Python
Raw Normal View History

from flask import request
from os import getcwd
from os.path import exists
2020-03-07 13:29:07 -06:00
from re import search
def is_docker():
return not exists(f'{getcwd()}/app')
def get_content_text():
if(str(request.url_rule == '/')):
if(is_docker()):
homepage_text_file = open(f'{getcwd()}/uwume/assets/content.txt')
else:
homepage_text_file = open(f'{getcwd()}/app/assets/content.txt')
else:
if(is_docker()):
homepage_text_file = open(
f'{getcwd()}/uwume/assets{request.url_rule}/content.txt')
else:
homepage_text_file = open(
f'{getcwd()}/app/assets{request.url_rule}/content.txt')
homepage_text = homepage_text_file.readlines()
try:
homepage_text.remove('\n')
except:
pass
return homepage_text
def get_static_paths():
if(str(request.url_rule) == '/'):
return (f'static/css/index.css', f'static/js/index.js')
else:
2020-03-07 13:29:07 -06:00
if('<' in str(request.url_rule)):
delete = search('<.*>', str(request.url_rule))
delete = '/' + delete.group(0)
new_path = str(request.url_rule).replace(delete, '')
return (f'static/css{new_path}/index.css', f'static/js{new_path}/index.js')
return (f'static/css{request.url_rule}/index.css', f'static/js{request.url_rule}/index.js')