Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,12 +2,12 @@ from flask import Flask, request, jsonify, send_from_directory, make_response
|
|
| 2 |
import os
|
| 3 |
import time
|
| 4 |
import random
|
|
|
|
| 5 |
from datetime import datetime
|
| 6 |
from werkzeug.utils import secure_filename
|
| 7 |
import requests
|
| 8 |
|
| 9 |
app = Flask(__name__)
|
| 10 |
-
app.config['COMPRESS_REGISTER'] = False
|
| 11 |
|
| 12 |
PUBLIC_DIR = 'public'
|
| 13 |
UPLOAD_DIR = 'uploads'
|
|
@@ -44,12 +44,6 @@ USER_AGENTS = [
|
|
| 44 |
def allowed_file(filename):
|
| 45 |
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
| 46 |
|
| 47 |
-
@app.after_request
|
| 48 |
-
def after_request(response):
|
| 49 |
-
response.headers['Content-Encoding'] = 'identity'
|
| 50 |
-
response.direct_passthrough = False
|
| 51 |
-
return response
|
| 52 |
-
|
| 53 |
@app.route('/')
|
| 54 |
def index():
|
| 55 |
return jsonify({
|
|
@@ -110,11 +104,13 @@ def get_url():
|
|
| 110 |
continue
|
| 111 |
|
| 112 |
if html_only:
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
|
|
|
|
|
|
| 118 |
|
| 119 |
return jsonify({
|
| 120 |
'success': True,
|
|
@@ -167,9 +163,12 @@ def fetch_with_ua(url, user_agent, html_only):
|
|
| 167 |
html = response.text
|
| 168 |
|
| 169 |
if html_only:
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
return jsonify({
|
| 175 |
'success': True,
|
|
|
|
| 2 |
import os
|
| 3 |
import time
|
| 4 |
import random
|
| 5 |
+
import base64
|
| 6 |
from datetime import datetime
|
| 7 |
from werkzeug.utils import secure_filename
|
| 8 |
import requests
|
| 9 |
|
| 10 |
app = Flask(__name__)
|
|
|
|
| 11 |
|
| 12 |
PUBLIC_DIR = 'public'
|
| 13 |
UPLOAD_DIR = 'uploads'
|
|
|
|
| 44 |
def allowed_file(filename):
|
| 45 |
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
@app.route('/')
|
| 48 |
def index():
|
| 49 |
return jsonify({
|
|
|
|
| 104 |
continue
|
| 105 |
|
| 106 |
if html_only:
|
| 107 |
+
html_b64 = base64.b64encode(html.encode('utf-8')).decode('utf-8')
|
| 108 |
+
return jsonify({
|
| 109 |
+
'success': True,
|
| 110 |
+
'html_base64': html_b64,
|
| 111 |
+
'user_agent': user_agent,
|
| 112 |
+
'attempts': len(failed_attempts) + 1
|
| 113 |
+
})
|
| 114 |
|
| 115 |
return jsonify({
|
| 116 |
'success': True,
|
|
|
|
| 163 |
html = response.text
|
| 164 |
|
| 165 |
if html_only:
|
| 166 |
+
html_b64 = base64.b64encode(html.encode('utf-8')).decode('utf-8')
|
| 167 |
+
return jsonify({
|
| 168 |
+
'success': True,
|
| 169 |
+
'html_base64': html_b64,
|
| 170 |
+
'user_agent': user_agent
|
| 171 |
+
})
|
| 172 |
|
| 173 |
return jsonify({
|
| 174 |
'success': True,
|