soojeongcrystal commited on
Commit
e241071
·
verified ·
1 Parent(s): e6f9bd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,9 +1,26 @@
1
  import streamlit as st
2
  import pandas as pd
 
 
 
3
 
4
  # Set page title and favicon
5
  st.set_page_config(page_title="고민 해결사", page_icon=":sunglasses:")
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  st.markdown("""
8
  <style>
9
  .header {
@@ -76,10 +93,11 @@ if submit_button_left:
76
 
77
  # Add advice section
78
  st.subheader("고민 조언해주기")
79
- st.write("다른 팀장님들의 고민에 대해 조언해주시겠어요?")
80
  advice = st.text_area(" ", height=100)
81
  submit_button_right = st.button("조언 제출하기")
82
-
83
  if submit_button_right:
84
- # TODO: Perform the task of saving the input advice
85
- st.write("조언이 제출되었습니다 : )")
 
 
1
  import streamlit as st
2
  import pandas as pd
3
+ import gspread
4
+ from oauth2client.service_account import ServiceAccountCredentials
5
+ from datetime import datetime
6
 
7
  # Set page title and favicon
8
  st.set_page_config(page_title="고민 해결사", page_icon=":sunglasses:")
9
 
10
+ # Google Sheets 인증 설정
11
+ scope = ["https://spreadsheets.google.com/feeds", "https://www.googleapis.com/auth/spreadsheets",
12
+ "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"]
13
+ creds = ServiceAccountCredentials.from_json_keyfile_name("/Users/crystal/generation/analog-marking-416002-e369840763fa.json", scope)
14
+ client = gspread.authorize(creds)
15
+
16
+ # Google Sheets 문서 열기
17
+ sheet = client.open("generation_streamlit_0302").sheet1
18
+
19
+ # 사용자 조언 데이터를 Google Sheets 문서에 추가하는 함수
20
+ def record_advice(concern, advice):
21
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
22
+ sheet.append_row([timestamp, concern, advice])
23
+
24
  st.markdown("""
25
  <style>
26
  .header {
 
93
 
94
  # Add advice section
95
  st.subheader("고민 조언해주기")
96
+ st.write(" 팀장님 고민에 대해 조언해주시겠어요?")
97
  advice = st.text_area(" ", height=100)
98
  submit_button_right = st.button("조언 제출하기")
99
+
100
  if submit_button_right:
101
+ # Google Sheets 문서에 조언 기록
102
+ record_advice("선택된 고민 내용", advice) # 여기서 "선택된 고민 내용"을 실제 고민 내용으로 대체해야 합니다.
103
+ st.success("조언이 성공적으로 제출되었습니다!")