amoldwalunj commited on
Commit
39cee1a
·
1 Parent(s): 75dc04b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +395 -144
app.py CHANGED
@@ -1,19 +1,193 @@
1
-
2
  import streamlit as st
3
- from fpdf import FPDF
4
  import base64
5
  import openai
6
  from streamlit_quill import st_quill
7
  import os
8
  from io import BytesIO
9
- #from weasyprint import HTML
10
- import tempfile
11
- import weasyprint
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- os.environ["OPENAI_API_KEY"] = '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'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  openai.api_key = os.getenv("OPENAI_API_KEY")
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  def get_chatgpt_response(messages):
18
  response = openai.ChatCompletion.create(
19
  model="gpt-3.5-turbo",
@@ -21,9 +195,12 @@ def get_chatgpt_response(messages):
21
  )
22
  return response['choices'][0]['message']['content']
23
 
 
 
 
 
24
  def process_text(inputs):
25
- # Perform some processing on the input dictionary here
26
- # For example, you could concatenate all the inputs into a single string
27
  processed_text = ""
28
  for key, value in inputs.items():
29
  processed_text += f"{key}: {value}\n\n"
@@ -36,84 +213,34 @@ def process_text(inputs):
36
  ]
37
 
38
  model_response = get_chatgpt_response(messages)
39
-
40
  return model_response
41
 
42
- # def save_as_pdf(text):
43
- # pdf = FPDF()
44
- # pdf.add_page()
45
- # pdf.set_font("Arial", size=12)
46
- # encoded_text = text.encode('latin-1', 'replace').decode('latin-1')
47
- # pdf.multi_cell(0, 10, txt=encoded_text)
48
- # file_name = "output.pdf"
49
- # pdf.output(file_name)
50
- # with open(file_name, "rb") as pdf_file:
51
- # b64 = base64.b64encode(pdf_file.read()).decode('utf-8')
52
- # href = f'<a href="data:application/octet-stream;base64,{b64}" download="{file_name}">Download PDF</a>'
53
- # st.markdown(href, unsafe_allow_html=True)
54
-
55
-
56
-
57
- # import base64
58
- # from io import BytesIO
59
- # from weasyprint import HTML
60
- # #from streamlit_quill import Delta, Renderer
61
- # from quill.delta import Delta
62
-
63
- # def save_as_pdf(text):
64
- # # convert quill editor HTML to PDF
65
- # pdf_file = BytesIO()
66
- # HTML(string=text).write_pdf(pdf_file, stylesheets=[CSS(string="""
67
- # .ql-editor {
68
- # font-size: 16px;
69
- # line-height: 1.6;
70
- # }
71
- # """)], style_tags=True)
72
-
73
- # # encode the PDF to base64
74
- # b64 = base64.b64encode(pdf_file.getvalue()).decode('utf-8')
75
-
76
- # # generate a download link for the PDF
77
- # href = f'<a href="data:application/octet-stream;base64,{b64}" download="output.pdf">Download PDF</a>'
78
- # st.markdown(href, unsafe_allow_html=True)
79
-
80
-
81
- import tempfile
82
- import weasyprint
83
- from bs4 import BeautifulSoup
84
-
85
- import pdfkit
86
 
87
- from docx import Document
88
  from io import BytesIO
89
- import base64
90
 
91
- def save_as_doc(text):
92
- # create a Word document
93
- doc = Document()
94
 
95
- # add the edited text to the document
96
- doc.add_paragraph(text)
97
 
98
- # save the document to a BytesIO object
99
- doc_file = BytesIO()
100
- doc.save(doc_file)
101
- doc_file.seek(0)
102
 
103
- # encode the document to base64
104
- b64 = base64.b64encode(doc_file.getvalue()).decode('utf-8')
105
 
106
- # generate a download link for the document
107
- href = f'<a href="data:application/octet-stream;base64,{b64}" download="output.docx">Download DOCX</a>'
108
- st.markdown(href, unsafe_allow_html=True)
 
109
 
 
110
 
111
 
112
 
113
  def form_page():
114
-
115
- st.markdown("### Your custom obituary writer :pencil:")
116
- st.markdown("### Please fill the details to get custom obituary")
117
 
118
  inputs = {
119
  "Full name, including any nicknames": "",
@@ -133,93 +260,118 @@ def form_page():
133
  for key in inputs:
134
  inputs[key] = st.text_input(key)
135
 
136
- if st.button("Process"):
137
- output_text = process_text(inputs)
138
- st.session_state.output_text = output_text
139
- st.write(output_text)
140
- st.session_state.form = True
 
 
 
 
 
141
 
142
- if st.session_state.form:
143
- if st.button("I want to add more information"):
144
- additional_info = st.text_input("What else would you like to add?")
145
- if additional_info:
146
- message = f"{additional_info}"
147
- output_text = get_chatgpt_response(message)
148
- st.session_state.output_text += "\n" + output_text
149
- st.write(st.session_state.output_text)
150
 
151
- if st.button("I want to export and edit manually"):
152
- st.session_state.export_manually = True
153
- st.session_state.form = False
154
- st.experimental_rerun()
155
 
 
 
 
 
 
 
156
 
157
 
158
- # def editor_page():
159
- # #st.markdown("### Editor :smile:")
160
- # st.markdown("<h1 style='text-align: center; color: Red;'>Editor</h1>", unsafe_allow_html=True)
161
 
162
- # st.write("Use the editor below to edit the obituary:")
 
163
 
 
 
164
 
165
- # quill_text = st.session_state.output_text
166
- # edited_text = st_quill(quill_text)
167
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
- # st.write("Here is the edited obituary:")
170
- # #st.write(edited_text)
 
 
 
 
171
 
172
- # st.session_state.edited_text= edited_text
 
 
173
 
174
- # if st.button("Save as PDF"):
175
- # # Save the output text as a PDF
176
- # #save_as_pdf(st.session_state.output_text)
177
- # save_as_pdf(st.session_state.edited_text)
178
- # st.write("The custom obituary has been saved as a PDF.")
179
 
180
- # # Add some custom CSS to style the editor
181
- # st.markdown("""
182
- # <style>
183
- # #toolbar {
184
- # background-color: #f3f3f3;
185
- # border-radius: 5px;
186
- # padding: 5px;
187
- # }
188
- # .ql-container {
189
- # border-radius: 5px;
190
- # border: 1px solid #ccc;
191
- # height: 400px;
192
- # }
193
- # .ql-editor {
194
- # height: 100%;
195
- # }
196
- # </style>
197
- # """, unsafe_allow_html=True)
198
 
199
 
200
- #from quill.delta import Delta, Renderer
201
 
 
 
 
202
 
203
 
204
  def editor_page():
205
- st.markdown("<h1 style='text-align: center; color: Red;'>Editor</h1>", unsafe_allow_html=True)
206
-
 
207
  st.write("Use the editor below to edit the obituary:")
208
 
209
  quill_text = st.session_state.output_text
210
- edited_text = st_quill(quill_text)
211
-
212
- st.write("Here is the edited obituary:")
213
- st.write(edited_text)
214
 
215
  st.session_state.edited_text = edited_text
 
216
 
217
  if st.button("Save as DOCX"):
218
- # Save the output text as a Word document
219
- save_as_doc(st.session_state.edited_text)
220
  st.write("The custom obituary has been saved as a Word document.")
221
 
222
- # Add some custom CSS to style the editor
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  st.markdown("""
224
  <style>
225
  #toolbar {
@@ -240,7 +392,8 @@ def editor_page():
240
  """, unsafe_allow_html=True)
241
 
242
 
243
-
 
244
 
245
 
246
  PAGES = {
@@ -249,17 +402,115 @@ PAGES = {
249
  }
250
 
251
  def app():
252
- if "form" not in st.session_state:
253
- st.session_state.form = False
254
- if "export_manually" not in st.session_state:
255
- st.session_state.export_manually = False
256
-
257
- if not st.session_state.export_manually:
258
- st.sidebar.radio("",["form"])
259
- form_page()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  else:
261
- st.sidebar.radio("",["Editor"])
262
- editor_page()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
 
264
  if __name__ == "__main__":
265
- app()
 
 
 
1
  import streamlit as st
2
+ #from fpdf import FPDF
3
  import base64
4
  import openai
5
  from streamlit_quill import st_quill
6
  import os
7
  from io import BytesIO
8
+ from docx import Document
9
+ import yagmail
10
+ import re
11
+ #import re
12
+ import html2text
13
+ from docx import Document
14
+ from docx.shared import Pt
15
+ from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
16
+ from docx.oxml.ns import qn
17
+ from docx.oxml import OxmlElement
18
+ from bs4 import BeautifulSoup
19
+
20
+
21
+ from html2docx import HTML2Docx
22
+
23
+ import streamlit as st
24
+ import streamlit.components.v1 as components
25
 
26
+ import streamlit as st
27
+ from captcha.image import ImageCaptcha
28
+ import random, string
29
+
30
+ # define the constant
31
+ length_captcha = 4
32
+ width = 380
33
+ height = 200
34
+
35
+
36
+ def read_index_html():
37
+ with open("index.html") as f:
38
+ return f.read()
39
 
40
+
41
+ custom_css = """
42
+ <style>
43
+ body {
44
+ background-color: #F8F9F9;
45
+ }
46
+ h1 {
47
+ color: #2980B9;
48
+ }
49
+ h2 {
50
+ color: #21618C;
51
+ }
52
+ h3 {
53
+ color: #1C2833;
54
+ }
55
+ input, textarea {
56
+ background-color: #F2F3F4;
57
+ border-radius: 5px;
58
+ }
59
+ button {
60
+ background-color: #2980B9;
61
+ color: white;
62
+ font-weight: bold;
63
+ border-radius: 5px;
64
+ }
65
+ a {
66
+ color: #2980B9;
67
+ }
68
+ .streamlit-button {
69
+ display: flex;
70
+ justify-content: center;
71
+ align-items: center;
72
+ }
73
+ .streamlit-button:hover {
74
+ background-color: #21618C;
75
+ }
76
+ </style>
77
+ """
78
+
79
+ # custom_css = """
80
+ # <style>
81
+ # body {
82
+ # background-color: #F8F9F9;
83
+ # }
84
+ # h1 {
85
+ # color: #2980B9;
86
+ # }
87
+ # h2 {
88
+ # color: #21618C;
89
+ # }
90
+ # h3 {
91
+ # color: #1C2833;
92
+ # }
93
+ # input, textarea {
94
+ # background-color: #F2F3F4;
95
+ # border-radius: 5px;
96
+ # }
97
+ # button {
98
+ # background-color: #2980B9;
99
+ # color: white;
100
+ # font-weight: bold;
101
+ # border-radius: 5px;
102
+ # }
103
+ # a {
104
+ # color: #2980B9;
105
+ # }
106
+ # .streamlit-button {
107
+ # display: flex;
108
+ # justify-content: center;
109
+ # align-items: center;
110
+ # color: white;
111
+ # }
112
+ # .streamlit-button:hover {
113
+ # background-color: #21618C;
114
+ # }
115
+ # .stTextInput > div > div > input {
116
+ # border: 1px solid #C0C0C0;
117
+ # border-radius: 5px;
118
+ # }
119
+ # </style>
120
+ # """
121
+
122
+
123
+ os.environ["OPENAI_API_KEY"] = 'sk-E'
124
  openai.api_key = os.getenv("OPENAI_API_KEY")
125
 
126
+ # define the function for the captcha control
127
+ def captcha_control():
128
+ # control if the captcha is correct
129
+ if 'controllo' not in st.session_state or st.session_state['controllo'] == False:
130
+ #st.title("Please verify the Captcha to proceed")
131
+ st.markdown("<h1 style='text-align: center;'>Please verify the Captcha to proceed</h1>", unsafe_allow_html=True)
132
+
133
+ # define the session state for control if the captcha is correct
134
+ st.session_state['controllo'] = False
135
+
136
+ # define the session state for the captcha text because it doesn't change during refreshes
137
+ if 'Captcha' not in st.session_state:
138
+ st.session_state['Captcha'] = ''.join(random.choices(string.ascii_uppercase + string.digits, k=length_captcha))
139
+ print("the captcha is: ", st.session_state['Captcha'])
140
+
141
+ # # setup the captcha widget
142
+ # image = ImageCaptcha(width=width, height=height)
143
+ # data = image.generate(st.session_state['Captcha'])
144
+ # st.image(data)
145
+ # capta2_text = st.text_input('Enter captcha text', max_chars=4)
146
+
147
+ # setup the captcha widget
148
+ # image = ImageCaptcha(width=width, height=height)
149
+ # data = image.generate(st.session_state['Captcha'])
150
+ # st.image(data)
151
+
152
+ # # Create a centered column with the same width as the captcha image
153
+ # left_col, center_col, right_col = st.columns([150, width, 150])
154
+
155
+ # capta2_text = center_col.text_input('Enter captcha text', max_chars=4)
156
+ # Create a centered column with the same width as the captcha image for the captcha image
157
+ image = ImageCaptcha(width=width, height=height)
158
+ data = image.generate(st.session_state['Captcha'])
159
+ left_col_img, center_col_img, right_col_img = st.columns([150, width, 150])
160
+ center_col_img.image(data)
161
+
162
+ # Create a centered column with the same width as the captcha image for the text input
163
+ left_col_input, center_col_input, right_col_input = st.columns([150, width, 150])
164
+ capta2_text = center_col_input.text_input('Enter captcha text', max_chars=4)
165
+
166
+ # Create a centered column with the same width as the captcha image for the button
167
+ left_col_btn, center_col_btn, right_col_btn = st.columns([150, width, 150])
168
+
169
+ if center_col_btn.button("Verify the code"):
170
+
171
+
172
+ #if st.button("Verify the code"):
173
+ print(capta2_text, st.session_state['Captcha'])
174
+ capta2_text = capta2_text.replace(" ", "")
175
+ # if the captcha is correct, the controllo session state is set to True
176
+ if st.session_state['Captcha'].lower() == capta2_text.lower().strip():
177
+ del st.session_state['Captcha']
178
+ st.session_state['controllo'] = True
179
+ st.experimental_rerun()
180
+ else:
181
+ # if the captcha is wrong, the controllo session state is set to False and the captcha is regenerated
182
+ st.error("🚨 The captcha code is incorrect, please try again.")
183
+ #st.write("🚨 The captcha code is incorrect, please try again.")
184
+ del st.session_state['Captcha']
185
+ del st.session_state['controllo']
186
+ st.experimental_rerun()
187
+ else:
188
+ # wait for the button click
189
+ st.stop()
190
+
191
  def get_chatgpt_response(messages):
192
  response = openai.ChatCompletion.create(
193
  model="gpt-3.5-turbo",
 
195
  )
196
  return response['choices'][0]['message']['content']
197
 
198
+ def update_chat(messages, role, content):
199
+ messages.append({"role": role, "content": content})
200
+ return messages
201
+
202
  def process_text(inputs):
203
+ global messages
 
204
  processed_text = ""
205
  for key, value in inputs.items():
206
  processed_text += f"{key}: {value}\n\n"
 
213
  ]
214
 
215
  model_response = get_chatgpt_response(messages)
 
216
  return model_response
217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
 
219
+ from html2docx import html2docx
220
  from io import BytesIO
 
221
 
 
 
 
222
 
 
 
223
 
224
+ def save_as_doc(text, html_content):
225
+ doc_title = "Custom Obituary"
226
+ buf = html2docx(html_content, title=doc_title)
227
+ filename = f"{doc_title}.docx"
228
 
229
+ with open(filename, "wb") as f:
230
+ f.write(buf.getvalue())
231
 
232
+ with open(filename, "rb") as f:
233
+ base64_content = base64.b64encode(f.read()).decode("utf-8")
234
+ href = f'<a href="data:application/octet-stream;base64,{base64_content}" download="{filename}" id="download-docx-link">Download</a>'
235
+ st.markdown(href, unsafe_allow_html=True)
236
 
237
+ os.remove(filename)
238
 
239
 
240
 
241
  def form_page():
242
+ st.markdown("### Free Obituary Writing Assistant :pencil:")
243
+ st.write("Complete any applicable fields below. If you don't know the answers, that's OK you can add them later")
 
244
 
245
  inputs = {
246
  "Full name, including any nicknames": "",
 
260
  for key in inputs:
261
  inputs[key] = st.text_input(key)
262
 
263
+ if st.button("Create Obituary"):
264
+
265
+ global messages
266
+ with st.spinner('Generating obituary...'):
267
+ output_text = process_text(inputs)
268
+ messages = update_chat(messages, "assistant", output_text)
269
+ st.session_state.output_text = output_text
270
+ st.session_state.messages = messages
271
+ #st.write(output_text)
272
+ st.session_state.form = True
273
 
 
 
 
 
 
 
 
 
274
 
 
 
 
 
275
 
276
+ if st.session_state.form:
277
+
278
+ output_placeholder = st.empty()
279
+ #output_placeholder.write(st.session_state.output_text)
280
+ #output_placeholder.markdown(f'<div style="background-color: #6495ED; color: white; padding: 10px; border-radius: 5px;">{st.session_state.output_text}</div>', unsafe_allow_html=True)
281
+ output_placeholder.markdown(f'<div style="background-color: #AED6F1; color: black; padding: 10px; border-radius: 5px;">{st.session_state.output_text}</div>', unsafe_allow_html=True)
282
 
283
 
284
+ if "additional_info" not in st.session_state:
285
+ st.session_state.additional_info = ""
 
286
 
287
+ if "additional_info_key" not in st.session_state:
288
+ st.session_state.additional_info_key = "additional_info_input_1"
289
 
290
+ additional_info_placeholder = st.empty()
291
+ additional_info = additional_info_placeholder.text_input("What else would you like to add?", value=st.session_state.additional_info, key=st.session_state.additional_info_key)
292
 
293
+ if st.button("I want to add more information"):
294
+
295
+ messages = st.session_state.messages
296
+ with st.spinner('Generating obituary...'):
297
+ if additional_info:
298
+ message = "can you please re-write this obituary by using earlier information and new information. Please make sure you write obituary little long. new information is here: " + additional_info
299
+ messages = update_chat(messages, "user", message)
300
+ output_text = get_chatgpt_response(messages)
301
+ messages = update_chat(messages, "assistant", output_text)
302
+ st.session_state.output_text = output_text
303
+ #output_placeholder.write(output_text)
304
+ #output_placeholder.markdown(f'<div style="background-color: #6495ED; color: white; padding: 10px; border-radius: 5px;">{output_text}</div>', unsafe_allow_html=True)
305
+ output_placeholder.markdown(f'<div style="background-color: #AED6F1; color: black; padding: 10px; border-radius: 5px;">{output_text}</div>', unsafe_allow_html=True)
306
+
307
+
308
+ st.session_state.additional_info = ""
309
+ st.session_state.additional_info_key = f"additional_info_input_{int(st.session_state.additional_info_key.split('_')[-1]) + 1}"
310
+ additional_info_placeholder.text_input("What else would you like to add?", value=st.session_state.additional_info, key=st.session_state.additional_info_key)
311
+
312
+
313
+ if st.button("I want to export and edit manually"):
314
+
315
+ st.session_state.export_manually = True
316
+ st.session_state.form = False
317
+ st.experimental_rerun()
318
 
319
+ # if not st.session_state.form:
320
+ # if st.button("I want to export and edit manually"):
321
+ # st.session_state.form = True
322
+ # else:
323
+ # if st.button("Go Back to Form"):
324
+ # st.session_state.form = False
325
 
326
+ def send_email(email, subject, content):
327
+ sender_email = "[email protected]" # Replace with your email
328
+ sender_password = "acolructdnephudf" # Replace with your email password
329
 
330
+ yag = yagmail.SMTP(sender_email, sender_password)
331
+ yag.send(to=email, subject=subject, contents=content)
 
 
 
332
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
 
334
 
 
335
 
336
+ def validate_email(email):
337
+ email_regex = r"[^@]+@[^@]+\.[^@]+"
338
+ return re.match(email_regex, email) is not None
339
 
340
 
341
  def editor_page():
342
+ #form_page()
343
+
344
+ st.markdown("<h1 style='text-align: center; color: Red;'>Obituary Draft</h1>", unsafe_allow_html=True)
345
  st.write("Use the editor below to edit the obituary:")
346
 
347
  quill_text = st.session_state.output_text
348
+ edited_text = st_quill(quill_text, html=True)
 
 
 
349
 
350
  st.session_state.edited_text = edited_text
351
+ #st.session_state.edited_html = edited_text['html']
352
 
353
  if st.button("Save as DOCX"):
354
+ html_content = st.session_state.edited_text
355
+ save_as_doc(st.session_state.edited_text, html_content)
356
  st.write("The custom obituary has been saved as a Word document.")
357
 
358
+ if "email_obituary" not in st.session_state:
359
+ st.session_state.email_obituary = False
360
+
361
+ if st.button("Email Obituary"):
362
+ st.session_state.email_obituary = not st.session_state.email_obituary
363
+
364
+ if st.session_state.email_obituary:
365
+ recipient_email = st.text_input("Enter your email address:", key="recipient_email")
366
+
367
+ if st.button("Send", key="send_email_button"):
368
+ if recipient_email and validate_email(recipient_email):
369
+ with st.spinner('Sending...'):
370
+ send_email(recipient_email, "Your Custom Obituary", st.session_state.edited_text)
371
+ st.success("Obituary sent to your email!")
372
+ else:
373
+ st.error("Please enter a valid email address.")
374
+
375
  st.markdown("""
376
  <style>
377
  #toolbar {
 
392
  """, unsafe_allow_html=True)
393
 
394
 
395
+
396
+
397
 
398
 
399
  PAGES = {
 
402
  }
403
 
404
  def app():
405
+
406
+ #st.markdown(custom_css, unsafe_allow_html=True)
407
+
408
+ # custom_css = """
409
+ # <style>
410
+
411
+ # /* Input box boundary */
412
+ # .stTextInput > div > div > input {
413
+ # border: 1px solid #C0C0C0;
414
+ # border-radius: 5px;
415
+ # }
416
+ # </style>
417
+ # """
418
+
419
+ st.markdown(custom_css, unsafe_allow_html=True)
420
+
421
+ # button_text_style = """
422
+ # <style>
423
+ # .stButton > button {
424
+ # color: white !important;
425
+ # }
426
+ # /* Button hover color */
427
+ # .stButton > button:hover {
428
+ # background-color: #45a049;
429
+ # }
430
+
431
+ # .stTextInput > div > div > input {
432
+ # border: 1px solid #C0C0C0;
433
+ # border-radius: 5px;
434
+ # }
435
+ # </style>
436
+ # """
437
+ # st.markdown(button_text_style, unsafe_allow_html=True)
438
+
439
+ button_text_style = """
440
+ <style>
441
+ .stButton > button {
442
+ color: white !important;
443
+ }
444
+
445
+ .stButton > button:hover {
446
+ background-color: #45a049;
447
+ color: red !important;
448
+ }
449
+
450
+ .stTextInput > div > div > input {
451
+ border: 1px solid #C0C0C0;
452
+ border-radius: 5px;
453
+ }
454
+ /* Background color for buttons */
455
+ .stButton > button {
456
+ background-color: #ff0290;
457
+ color: white;
458
+ }
459
+
460
+ </style>
461
+ """
462
+
463
+ st.markdown(button_text_style, unsafe_allow_html=True)
464
+
465
+
466
+ hide_streamlit_style = """
467
+ <style>
468
+ #MainMenu {visibility: hidden;}
469
+ footer {visibility: hidden;}
470
+ </style>
471
+ """
472
+ st.markdown(hide_streamlit_style, unsafe_allow_html=True)
473
+
474
+ hide_decoration_bar_style = '''
475
+ <style>
476
+ header {visibility: hidden;}
477
+ </style>
478
+ '''
479
+ st.markdown(hide_decoration_bar_style, unsafe_allow_html=True)
480
+
481
+ #reduce top margin
482
+ reduce_header_height_style = """
483
+ <style>
484
+ div.block-container {padding-top:0.01rem;}
485
+ </style>
486
+ """
487
+ st.markdown(reduce_header_height_style, unsafe_allow_html=True)
488
+
489
+ if 'controllo' not in st.session_state or st.session_state['controllo'] == False:
490
+ captcha_control()
491
  else:
492
+
493
+ if "form" not in st.session_state:
494
+ st.session_state.form = False
495
+ if "export_manually" not in st.session_state:
496
+ st.session_state.export_manually = False
497
+
498
+ if not st.session_state.export_manually:
499
+ form_page()
500
+ components.html(
501
+ read_index_html(),
502
+ height=0,
503
+ width=0,
504
+ )
505
+ else:
506
+ editor_page()
507
+
508
+ components.html(
509
+ read_index_html(),
510
+ height=0,
511
+ width=0,
512
+ )
513
 
514
  if __name__ == "__main__":
515
+
516
+ app()