Update app.py
Browse files
app.py
CHANGED
@@ -175,6 +175,46 @@
|
|
175 |
#
|
176 |
#0----------------
|
177 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
# Layout with three columns
|
180 |
col1, col2, col3 = st.columns(3)
|
@@ -230,3 +270,39 @@ else:
|
|
230 |
|
231 |
st.header("π Game Scenario & Script")
|
232 |
st.write(combined_content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
#
|
176 |
#0----------------
|
177 |
import streamlit as st
|
178 |
+
import smtplib
|
179 |
+
from email.mime.text import MIMEText
|
180 |
+
from email.mime.multipart import MIMEMultipart
|
181 |
+
from pydrive.auth import GoogleAuth
|
182 |
+
from pydrive.drive import GoogleDrive
|
183 |
+
import urllib.parse
|
184 |
+
|
185 |
+
# Function to send an email with the script
|
186 |
+
def send_email(to_email, subject, body):
|
187 |
+
from_email = "[email protected]"
|
188 |
+
password = "your_email_password"
|
189 |
+
|
190 |
+
msg = MIMEMultipart()
|
191 |
+
msg['From'] = from_email
|
192 |
+
msg['To'] = to_email
|
193 |
+
msg['Subject'] = subject
|
194 |
+
msg.attach(MIMEText(body, 'plain'))
|
195 |
+
|
196 |
+
server = smtplib.SMTP('smtp.gmail.com', 587)
|
197 |
+
server.starttls()
|
198 |
+
server.login(from_email, password)
|
199 |
+
server.sendmail(from_email, to_email, msg.as_string())
|
200 |
+
server.quit()
|
201 |
+
|
202 |
+
# Function to upload the script to Google Drive and get a shareable link
|
203 |
+
def upload_to_drive(file_name, file_content):
|
204 |
+
gauth = GoogleAuth()
|
205 |
+
gauth.LocalWebserverAuth()
|
206 |
+
drive = GoogleDrive(gauth)
|
207 |
+
|
208 |
+
file = drive.CreateFile({'title': file_name})
|
209 |
+
file.SetContentString(file_content)
|
210 |
+
file.Upload()
|
211 |
+
|
212 |
+
file.InsertPermission({
|
213 |
+
'type': 'anyone',
|
214 |
+
'value': 'anyone',
|
215 |
+
'role': 'reader'
|
216 |
+
})
|
217 |
+
return file['alternateLink']
|
218 |
|
219 |
# Layout with three columns
|
220 |
col1, col2, col3 = st.columns(3)
|
|
|
270 |
|
271 |
st.header("π Game Scenario & Script")
|
272 |
st.write(combined_content)
|
273 |
+
|
274 |
+
# Add a download button to save the script
|
275 |
+
st.download_button(
|
276 |
+
label="πΎ Download Script",
|
277 |
+
data=combined_content,
|
278 |
+
file_name="game_script.txt",
|
279 |
+
mime="text/plain"
|
280 |
+
)
|
281 |
+
|
282 |
+
# Email sharing option
|
283 |
+
to_email = st.text_input("Enter recipient email address:")
|
284 |
+
if st.button("π§ Send Script via Email"):
|
285 |
+
if to_email:
|
286 |
+
send_email(to_email, "Your Game Script", combined_content)
|
287 |
+
st.success(f"Script sent to {to_email} successfully!")
|
288 |
+
|
289 |
+
# Google Drive sharing option
|
290 |
+
if st.button("π Upload & Get Shareable Link"):
|
291 |
+
link = upload_to_drive("game_script.txt", combined_content)
|
292 |
+
st.success("File uploaded successfully!")
|
293 |
+
st.write(f"Shareable Link: {link}")
|
294 |
+
|
295 |
+
# WhatsApp sharing option
|
296 |
+
phone_number = st.text_input("Enter phone number with country code:")
|
297 |
+
if st.button("π² Share via WhatsApp"):
|
298 |
+
if phone_number:
|
299 |
+
message = combined_content
|
300 |
+
encoded_message = urllib.parse.quote(message)
|
301 |
+
url = f"https://api.whatsapp.com/send?phone={phone_number}&text={encoded_message}"
|
302 |
+
st.markdown(f"[Click to Share on WhatsApp]({url})")
|
303 |
+
|
304 |
+
# Shareable web page link (assuming Streamlit is deployed)
|
305 |
+
if st.button("Generate Shareable Link"):
|
306 |
+
app_base_url = "https://your-streamlit-app-url" # Replace with your deployed app's base URL
|
307 |
+
script_link = app_base_url + "/script?content=" + urllib.parse.quote(combined_content)
|
308 |
+
st.write(f"Shareable Link: {script_link}")
|