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 |
|
@@ -36,15 +36,9 @@ def proxy():
|
|
36 |
for tag in soup.find_all(src=True):
|
37 |
tag['src'] = '/proxy?url=' + tag['src']
|
38 |
content = str(soup)
|
39 |
-
with open("forward.html", "w") as f:
|
40 |
-
f.write(content)
|
41 |
-
|
42 |
-
with open("forward.html", "r") as f:
|
43 |
-
content = f.read()
|
44 |
-
|
45 |
|
46 |
|
47 |
-
return content, response.status_code, headers
|
48 |
except requests.RequestException as e:
|
49 |
return jsonify({'error': str(e)}), 500
|
50 |
|
|
|
1 |
+
from flask import Flask, request, jsonify, Response
|
2 |
from bs4 import BeautifulSoup
|
3 |
import requests
|
4 |
|
|
|
36 |
for tag in soup.find_all(src=True):
|
37 |
tag['src'] = '/proxy?url=' + tag['src']
|
38 |
content = str(soup)
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
|
41 |
+
return Response(content, status=response.status_code, headers=headers)
|
42 |
except requests.RequestException as e:
|
43 |
return jsonify({'error': str(e)}), 500
|
44 |
|