Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, request, jsonify,
|
| 2 |
from bs4 import BeautifulSoup
|
| 3 |
import requests
|
| 4 |
|
|
@@ -28,7 +28,7 @@ def proxy():
|
|
| 28 |
data=data,
|
| 29 |
allow_redirects=False
|
| 30 |
)
|
| 31 |
-
|
| 32 |
print(response.headers.items())
|
| 33 |
if response.headers.get('content-type', '').startswith('text/html'):
|
| 34 |
|
|
@@ -38,9 +38,9 @@ def proxy():
|
|
| 38 |
for tag in soup.find_all(src=True):
|
| 39 |
tag['src'] = '/proxy?url=' + tag['src']
|
| 40 |
content = str(soup)
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
except requests.RequestException as e:
|
| 45 |
return jsonify({'error': str(e)}), 500
|
| 46 |
|
|
|
|
| 1 |
+
from flask import Flask, request, jsonify, render_template
|
| 2 |
from bs4 import BeautifulSoup
|
| 3 |
import requests
|
| 4 |
|
|
|
|
| 28 |
data=data,
|
| 29 |
allow_redirects=False
|
| 30 |
)
|
| 31 |
+
|
| 32 |
print(response.headers.items())
|
| 33 |
if response.headers.get('content-type', '').startswith('text/html'):
|
| 34 |
|
|
|
|
| 38 |
for tag in soup.find_all(src=True):
|
| 39 |
tag['src'] = '/proxy?url=' + tag['src']
|
| 40 |
content = str(soup)
|
| 41 |
+
return render_template("public/forward.html", content=content)
|
| 42 |
+
else:
|
| 43 |
+
return Response(response.content, status=response.status_code)
|
| 44 |
except requests.RequestException as e:
|
| 45 |
return jsonify({'error': str(e)}), 500
|
| 46 |
|