-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
71 lines (51 loc) · 1.71 KB
/
main.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import streamlit as st
import os
import sys
from pathlib import Path
import django
PROJECT_ROOT_DIR = Path(os.path.abspath(__file__))
DJANGO_ROOT_DIR = PROJECT_ROOT_DIR / "y"
def django_setup() -> None:
"""
Allows to setup Django if it's not already running on a server. Should be called before any Django imports.
"""
# Add the project base directory to the sys.path
sys.path.append(DJANGO_ROOT_DIR.as_posix())
# The DJANGO_SETTINGS_MODULE has to be set to allow us to access django imports
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "y.settings"
)
# This is for setting up django
django.setup()
django_setup()
from core.models import Task, Child
if "page" not in st.session_state:
st.session_state.page = 0
main = st.empty()
sub = st.empty()
def nextpage():
st.session_state.page += 1
main.empty()
if st.session_state.page == 0:
with main.container():
st.title("привет, нурали и ислам")
name = st.selectbox(
'Выбери под кем зайти',
('нурали', 'ислам')
)
password = st.text_input('Введи пароль', type='password')
st.session_state.user = Child.objects.get(name=name)
if st.session_state.user.password == password:
nextpage()
if st.session_state.page > 0:
with sub.container():
# print(user)
# print(use)
task = st.session_state.user.tasks.get(id=st.session_state.page)
st.header(task.title)
st.subheader(task.text)
answer = st.text_input('Введи ответ')
if task.answer == answer:
task.is_done = True
task.save()
nextpage()