Spaces:
Runtime error
Runtime error
File size: 1,555 Bytes
2f50f00 598a7ac 2f50f00 0696ff7 598a7ac 399c94a 257020e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import streamlit as st
import json
import shutil
from common.tinderwrapper import TinderWrapper
from common.helpers import create_folder, save_data
with open('config.json', 'r') as f:
config = json.load(f)
APP_NAME = config['APP_NAME']
APP_LOGO = config['APP_LOGO']
APP_DESCRIPTION = config['APP_DESCRIPTION']
DUMP_FOLDER = config['DUMP_FOLDER']
def update_progress(percent, text):
progress_bar.progress(percent)
status_text.text(text)
st.set_page_config(page_title=APP_NAME)
st.title(APP_NAME)
st.image(APP_LOGO, use_column_width=True)
st.markdown(APP_DESCRIPTION)
access_token = st.text_input('Tinder Access Token', help='Токен доступа, полученный из запроса Tinder')
if st.button('Запуск'):
if not access_token:
st.error('Необходимо задать токен доступа')
else:
progress_bar = st.progress(0)
status_text = st.empty()
wrapper = TinderWrapper(access_token)
create_folder(DUMP_FOLDER)
try:
dump = wrapper.create_dump(update_progress)
save_data(dump, DUMP_FOLDER, update_progress)
shutil.make_archive('output', 'zip', DUMP_FOLDER)
update_progress(1.0, 'Обработка успешно завершена!')
with open('output.zip', 'rb') as f:
st.download_button('Скачать архив', f, file_name='output.zip')
except Exception as e:
st.error(e)
update_progress(1.0, 'Возникла ошибка!') |