From ef757eb224f6bae7647a58bfb559cd0ccf4345ac Mon Sep 17 00:00:00 2001 From: Reihan Date: Wed, 30 Apr 2025 00:31:55 +0700 Subject: [PATCH] init --- .dockerignore | 26 +++++ .gitignore | 44 +++++++++ Dockerfile | 16 ++++ app.py | 234 +++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 13 +++ requirements.txt | Bin 0 -> 92 bytes 6 files changed, 333 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 app.py create mode 100644 docker-compose.yml create mode 100644 requirements.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b31fa13 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,26 @@ +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +env/ +venv/ +.env +.venv +pip-log.txt +pip-delete-this-directory.txt +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.pytest_cache/ +.git +.gitignore +README.md +Dockerfile +docker-compose.yml +test.py \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..faa3813 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +test.py +# Virtual Environment +venv/ +ENV/ +.env +.venv + +# IDE +.idea/ +.vscode/ +*.swp +*.swo + +# Docker +.docker/ + +# Logs +*.log + +# System Files +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3792421 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.11-slim + +WORKDIR /app + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 5000 + +ENV FLASK_APP=app.py +ENV FLASK_ENV=production +ENV HOST=0.0.0.0 + +CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app", "--workers", "4"] \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..49cce98 --- /dev/null +++ b/app.py @@ -0,0 +1,234 @@ +import datetime +from flask import Flask, jsonify +from flask_cors import CORS +import resend +from flask import request + + +app = Flask(__name__) +CORS(app, resources={ + r"/*": { + "origins": ["*"], + "methods": ["GET", "POST", "OPTIONS"], + "allow_headers": ["Content-Type"] + } +}) + +# from supabase import create_client, Client +# SUPABASE_URL = "https://supabase-core.dev3vds1.link/" +# SUPABASE_KEY = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJzdXBhYmFzZSIsImlhdCI6MTc0NTk0MzYwMCwiZXhwIjo0OTAxNjE3MjAwLCJyb2xlIjoiYW5vbiJ9.28hFArcAFQ3mYTYL2n7nno4nHu5ZszkOO0dkAURR6Yg" +# supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY) + +resend.api_key = "re_XvLrRZMH_3mumWA531UugMk1X7A67fhH7" + + +@app.route('/send_email', methods=['POST']) +def send_email(): + try: + data = request.get_json() + email = data.get('email', 'with.reihan@gmail.com') + if not email: + return jsonify({'status': 'error', 'message': 'Email is required'}), 400 + # Check if the email is valid + if not isinstance(email, str) or '@' not in email: + return jsonify({'status': 'error', 'message': 'Invalid email format'}), 400 + + username = email.split('@')[0] + date = str(datetime.datetime.now().date()) + product = data.get('product', 'NVIDIA-686') + price_hour = data.get('price_hour', '2.00') + price = data.get('price', '147.00') + + html = f""" + + + + + + VertexGPU Invoice + + +
+ +
+
VertexGPU
+
+ + +
+ + + + + + + + +
Date Issued: {date} + Client ID: + VX-CLIENT-686 +
User: {username}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ Description + + Duration + RateAmount
{product}30 Days${price_hour}/hour${price}
Priority Support Package1 Month$00.00$00.00
+ + +
+ + + + + + + + + + + + + +
Subtotal:${price}
Network Fee:$0.00
Total Due: + ${price} +
+
+ + +
+

GPU Status Update

+

+ Your GPU instance is being initialized and will be ready for access within the next 2 hours. Once + configuration is complete, we'll send your authentication credentials to your registered email + address. +

+

+ For any assistance, our support team is available 24/7. Thank you for choosing our service. +

+
+ + +
+

+ Thank you for choosing VertexGPU for your high-performance computing needs! +

+

+ Visit us at + vertexgpu.com +

+

+ Questions? Contact us at + support@vertexgpu.com +

+
+
+ +""" + + # Send email using Resend + params: resend.Emails.SendParams = { + "from": "Vertex (no-reply) ", + "to": [email], + "subject": "Thanks for purchasing our product!", + "html": html, + } + + email = resend.Emails.send(params) + print(email) + return jsonify({'status': 'success', 'message': 'email sent'}) + except: + return jsonify({'status': 'error', 'message': 'Failed to send email'}), 500 + +@app.route('/health') +def health(): + return jsonify({'status': 'success', 'message': 'ok'}) + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9c056d1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: "3.8" + +services: + web: + build: . + ports: + - "5001:5000" + environment: + - FLASK_APP=app.py + - FLASK_ENV=development + volumes: + - .:/app + restart: unless-stopped diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..9b2c97536f88722430326d0de213c83974dc9b6e GIT binary patch literal 92 zcmezWFO4CGA(5e&A)A4hfr|mb(`86z$Y&@5%7Dbv8A=)Q7&4(^d0??3hE#?^pm-`! QO$k&TNURu$^B7VX0D^rH!T