thinh-vu commited on
Commit
8cdf44b
1 Parent(s): 5d7b81b

Create init.py

Browse files
Files changed (1) hide show
  1. init.py +54 -0
init.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import subprocess
4
+ import sys
5
+
6
+ import welcome
7
+
8
+ st.set_page_config(
9
+ page_title="TradingView Chart for Stock Market Analysis",
10
+ page_icon="📊",
11
+ layout="wide",
12
+ )
13
+
14
+ # it's the first time running the app and the session state is not initialized then show the welcome page
15
+ if "authentication_status" not in st.session_state:
16
+ welcome.render() # render the welcome page
17
+
18
+ secure_repo = st.secrets["private_repo"]
19
+ git_user = st.secrets["git_usr"]
20
+ git_token = st.secrets["MCGtk"]
21
+
22
+ def core_engine_setup():
23
+ repo_url = "https://<user>:<token>@github.com/<user>/<repo>.git"
24
+ # Replace <token> with the environment variable for your GitHub PAT
25
+ secure_url = repo_url.replace("<token>", git_token).replace("<user>", git_user).replace("<repo>", secure_repo)
26
+ # subprocess.run(f"pip install git+{secure_url}", shell=True, check=True)
27
+ subprocess.run(["git", "clone", secure_url])
28
+
29
+ try:
30
+ core_engine_setup()
31
+ os.chdir(secure_repo)
32
+ print('The core engine initialized successfully!')
33
+ subprocess.run(f"ls -l", shell=True, check=True)
34
+ subprocess.run(f"pip install -r requirements.txt", shell=True, check=True)
35
+
36
+ from app import technical_tab
37
+ from authen import authorize
38
+
39
+ auth, conf = authorize.load_config()
40
+ auth.login()
41
+
42
+ if st.session_state["authentication_status"]:
43
+ chart_tab, account_tab = st.tabs(['Home', 'Account'])
44
+
45
+ with chart_tab:
46
+ technical_tab.render()
47
+
48
+ with account_tab:
49
+ st.write(f'Xin chào *{st.session_state["name"]}*!')
50
+ st.markdown('### Đăng xuất')
51
+ auth.logout('Đăng xuất')
52
+
53
+ except:
54
+ st.warning('Something went wrong! Please try again!')