Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, request, jsonify, send_from_directory
|
| 2 |
import os
|
| 3 |
import time
|
| 4 |
import random
|
|
@@ -102,11 +102,15 @@ def get_url():
|
|
| 102 |
continue
|
| 103 |
|
| 104 |
if html_only:
|
| 105 |
-
return
|
| 106 |
-
|
| 107 |
-
'
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
return jsonify({
|
| 112 |
'success': True,
|
|
@@ -159,7 +163,7 @@ def fetch_with_ua(url, user_agent, html_only):
|
|
| 159 |
html = response.text
|
| 160 |
|
| 161 |
if html_only:
|
| 162 |
-
return html,
|
| 163 |
|
| 164 |
return jsonify({
|
| 165 |
'success': True,
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify, send_from_directory, Response
|
| 2 |
import os
|
| 3 |
import time
|
| 4 |
import random
|
|
|
|
| 102 |
continue
|
| 103 |
|
| 104 |
if html_only:
|
| 105 |
+
return Response(
|
| 106 |
+
html,
|
| 107 |
+
mimetype='text/html',
|
| 108 |
+
headers={
|
| 109 |
+
'Content-Type': 'text/html; charset=utf-8',
|
| 110 |
+
'X-User-Agent': user_agent,
|
| 111 |
+
'X-Attempts': str(len(failed_attempts) + 1)
|
| 112 |
+
}
|
| 113 |
+
)
|
| 114 |
|
| 115 |
return jsonify({
|
| 116 |
'success': True,
|
|
|
|
| 163 |
html = response.text
|
| 164 |
|
| 165 |
if html_only:
|
| 166 |
+
return Response(html, mimetype='text/html')
|
| 167 |
|
| 168 |
return jsonify({
|
| 169 |
'success': True,
|