Spaces:
Build error
Build error
Commit
·
6ea0c6b
1
Parent(s):
f69f054
attachment added, Dockerfile added
Browse files- Dockerfile +28 -0
- app.py +24 -4
Dockerfile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use Python slim as base image
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Install system dependencies
|
| 8 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
+
build-essential \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
+
|
| 12 |
+
# Copy requirements and install dependencies
|
| 13 |
+
COPY requirements.txt .
|
| 14 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
+
|
| 16 |
+
# Copy application code
|
| 17 |
+
COPY app.py .
|
| 18 |
+
|
| 19 |
+
# Expose port
|
| 20 |
+
EXPOSE 7860
|
| 21 |
+
|
| 22 |
+
# Environment variables for configuration
|
| 23 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0" \
|
| 24 |
+
GRADIO_SERVER_PORT="7860" \
|
| 25 |
+
GRADIO_SHARE="false"
|
| 26 |
+
|
| 27 |
+
# Run the application
|
| 28 |
+
ENTRYPOINT ["python", "app.py"]
|
app.py
CHANGED
|
@@ -4,8 +4,13 @@ import os
|
|
| 4 |
import time
|
| 5 |
import smtplib
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
# Validate inputs
|
| 10 |
if not file_txt:
|
| 11 |
raise gr.Error("Lütfen mail listesi dosyasını yükleyin")
|
|
@@ -58,7 +63,11 @@ def execute(file_txt, user_mail, google_api_key, subject_text, content):
|
|
| 58 |
continue
|
| 59 |
|
| 60 |
try:
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
successful_sends += 1
|
| 63 |
print(f"Mail gönderildi: {mail}")
|
| 64 |
time.sleep(0.2) # Rate limiting
|
|
@@ -132,6 +141,13 @@ with gr.Blocks() as demo:
|
|
| 132 |
lines=5
|
| 133 |
)
|
| 134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
with gr.Row():
|
| 136 |
create_button = gr.Button('📧 Mail Gönder', variant='primary')
|
| 137 |
|
|
@@ -141,7 +157,7 @@ with gr.Blocks() as demo:
|
|
| 141 |
# Connect the button click to the function
|
| 142 |
create_button.click(
|
| 143 |
fn=execute,
|
| 144 |
-
inputs=[file_input, user_mail, google_api_key, subject_text, content],
|
| 145 |
outputs=output
|
| 146 |
)
|
| 147 |
|
|
@@ -176,4 +192,8 @@ with gr.Blocks() as demo:
|
|
| 176 |
|
| 177 |
|
| 178 |
if __name__ == "__main__":
|
| 179 |
-
demo.launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import time
|
| 5 |
import smtplib
|
| 6 |
|
| 7 |
+
# Get server configuration from environment variables with defaults
|
| 8 |
+
SERVER_NAME = os.getenv("GRADIO_SERVER_NAME", "0.0.0.0")
|
| 9 |
+
SERVER_PORT = int(os.getenv("GRADIO_SERVER_PORT", "7860"))
|
| 10 |
+
SHARE_APP = os.getenv("GRADIO_SHARE", "false").lower() == "true"
|
| 11 |
|
| 12 |
+
|
| 13 |
+
def execute(file_txt, user_mail, google_api_key, subject_text, content, attachments=None):
|
| 14 |
# Validate inputs
|
| 15 |
if not file_txt:
|
| 16 |
raise gr.Error("Lütfen mail listesi dosyasını yükleyin")
|
|
|
|
| 63 |
continue
|
| 64 |
|
| 65 |
try:
|
| 66 |
+
# Handle attachments if any
|
| 67 |
+
if attachments:
|
| 68 |
+
yag.send(mail, subject_text, content, attachments=attachments)
|
| 69 |
+
else:
|
| 70 |
+
yag.send(mail, subject_text, content)
|
| 71 |
successful_sends += 1
|
| 72 |
print(f"Mail gönderildi: {mail}")
|
| 73 |
time.sleep(0.2) # Rate limiting
|
|
|
|
| 141 |
lines=5
|
| 142 |
)
|
| 143 |
|
| 144 |
+
with gr.Row():
|
| 145 |
+
attachments = gr.File(
|
| 146 |
+
label='Eklenecek dosyalar (birden fazla seçebilirsiniz)',
|
| 147 |
+
file_count='multiple',
|
| 148 |
+
file_types=['.pdf', '.doc', '.docx', '.txt', '.jpg', '.jpeg', '.png', '.zip']
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
with gr.Row():
|
| 152 |
create_button = gr.Button('📧 Mail Gönder', variant='primary')
|
| 153 |
|
|
|
|
| 157 |
# Connect the button click to the function
|
| 158 |
create_button.click(
|
| 159 |
fn=execute,
|
| 160 |
+
inputs=[file_input, user_mail, google_api_key, subject_text, content, attachments],
|
| 161 |
outputs=output
|
| 162 |
)
|
| 163 |
|
|
|
|
| 192 |
|
| 193 |
|
| 194 |
if __name__ == "__main__":
|
| 195 |
+
demo.launch(
|
| 196 |
+
server_name=SERVER_NAME,
|
| 197 |
+
server_port=SERVER_PORT,
|
| 198 |
+
share=SHARE_APP
|
| 199 |
+
)
|