|
from flask import Flask, request, render_template_string, send_from_directory, jsonify |
|
from flask import render_template |
|
import sqlite3 |
|
import os |
|
import uuid |
|
import yt_dlp |
|
import json |
|
import base64 |
|
import unittest |
|
import requests |
|
|
|
own_url = os.getenv('own_url') |
|
key_d = os.getenv('gc_api') |
|
gc_url = os.getenv('gc_url') |
|
|
|
|
|
|
|
|
|
|
|
import json |
|
from datetime import datetime |
|
|
|
import whatsapp_api_webhook_server_python.webhooksHandler as handler |
|
|
|
app = Flask(__name__, template_folder="./") |
|
|
|
|
|
|
|
|
|
app.config['DEBUG'] = True |
|
|
|
UPLOAD_FOLDER = 'static' |
|
|
|
|
|
|
|
if not os.path.exists(UPLOAD_FOLDER): |
|
os.makedirs(UPLOAD_FOLDER) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/upload', methods=['POST']) |
|
def upload_file(): |
|
if 'file' not in request.files: |
|
return "No file part", 400 |
|
file = request.files['file'] |
|
if file.filename == '': |
|
return "No selected file", 400 |
|
|
|
|
|
unique_filename = str(uuid.uuid4()) + os.path.splitext(file.filename)[1] |
|
save_path = os.path.join(UPLOAD_FOLDER, unique_filename) |
|
file.save(save_path) |
|
|
|
|
|
full_url = request.url_root.replace('http://', 'https://') + 'uploads/' + unique_filename |
|
return f"File uploaded successfully and saved to {full_url}", 200 |
|
|
|
@app.route('/uploads/<filename>', methods=['GET']) |
|
def uploaded_file(filename): |
|
return send_from_directory(UPLOAD_FOLDER, filename) |
|
|
|
@app.route('/up_fa', methods=['GET']) |
|
def up_fa(): |
|
return render_template('up_fa.html') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 7860))) |
|
|