Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, Response, request, abort
|
| 2 |
import requests
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
from urllib.parse import urljoin, urlparse
|
|
@@ -42,6 +42,27 @@ def download_and_replace_links(url):
|
|
| 42 |
|
| 43 |
return str(soup)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
# Flask route to proxy requests
|
| 46 |
@app.route('/proxy')
|
| 47 |
def proxy():
|
|
|
|
| 1 |
+
from flask import Flask, Response, request, abort, render_template_string
|
| 2 |
import requests
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
from urllib.parse import urljoin, urlparse
|
|
|
|
| 42 |
|
| 43 |
return str(soup)
|
| 44 |
|
| 45 |
+
# Flask route to serve index page
|
| 46 |
+
@app.route('/')
|
| 47 |
+
def index():
|
| 48 |
+
return render_template_string('''
|
| 49 |
+
<!doctype html>
|
| 50 |
+
<html lang="en">
|
| 51 |
+
<head>
|
| 52 |
+
<meta charset="utf-8">
|
| 53 |
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
| 54 |
+
<title>Proxy Service</title>
|
| 55 |
+
</head>
|
| 56 |
+
<body>
|
| 57 |
+
<div class="container">
|
| 58 |
+
<h1 class="mt-5">Welcome to the Proxy Service</h1>
|
| 59 |
+
<p class="lead">To use the proxy, append the URL parameter like this:</p>
|
| 60 |
+
<p><code>/proxy?url=http://example.com</code></p>
|
| 61 |
+
</div>
|
| 62 |
+
</body>
|
| 63 |
+
</html>
|
| 64 |
+
''')
|
| 65 |
+
|
| 66 |
# Flask route to proxy requests
|
| 67 |
@app.route('/proxy')
|
| 68 |
def proxy():
|