Skip to content

Commit

Permalink
Format files
Browse files Browse the repository at this point in the history
  • Loading branch information
wasi-master committed Aug 14, 2024
1 parent c641ec6 commit d7260eb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
12 changes: 10 additions & 2 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand All @@ -17,18 +18,20 @@
align-items: center;
height: 90vh;
}

h1 {
font-size: 1.5rem;
margin-bottom: 20px;
text-align: center;
color: #333;
}

label {
display: block;
margin-bottom: 10px;
font-weight: bold;
}

input[type=text] {
padding: 10px;
margin-bottom: 10px;
Expand All @@ -38,6 +41,7 @@
font-size: 1rem;
box-sizing: border-box;
}

input[type="submit"] {
padding: 10px;
background-color: #6a0dad;
Expand All @@ -50,6 +54,7 @@
cursor: pointer;
transition: background-color 0.3s ease;
}

input[type="submit"]:hover {
background-color: #4e0875;
}
Expand All @@ -59,12 +64,14 @@
form {
padding: 10px;
}

h1 {
font-size: 1.2rem;
}
}
</style>
</head>

<body>
<form action="/article" method="post">
<h1>Enter Website Link</h1>
Expand All @@ -73,4 +80,5 @@ <h1>Enter Website Link</h1>
<input type="submit" value="Submit">
</form>
</body>
</html>

</html>
11 changes: 7 additions & 4 deletions app/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ def bypass_paywall(url):
response = requests.get(url, headers=googlebot_headers)
response.encoding = response.apparent_encoding
return response.text

try:
return bypass_paywall("https://" + url)
except requests.exceptions.RequestException as e:
return bypass_paywall("http://" + url)


@app.route("/")
def main_page():
return flask.send_from_directory(".", "index.html")
Expand All @@ -37,14 +38,15 @@ def show_article():
except e:
raise e


@app.route("/", defaults={"path": ""})
@app.route('/<path:path>', methods=["GET"])
@app.route("/<path:path>", methods=["GET"])
def get_article(path):
print(path)
full_url = request.url
parts = full_url.split('/',4)
parts = full_url.split("/", 4)
if len(parts) >= 5:
actual_url = 'https://' + parts[4].lstrip('/')
actual_url = "https://" + parts[4].lstrip("/")
print(actual_url)
try:
return bypass_paywall(actual_url)
Expand All @@ -55,4 +57,5 @@ def get_article(path):
else:
return "Invalid URL", 400


app.run(debug=False)
10 changes: 6 additions & 4 deletions app/portable.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
</html>
"""


def bypass_paywall(url):
"""
Bypass paywall for a given url
Expand All @@ -109,13 +110,14 @@ def show_article():
except e:
raise e


@app.route("/", defaults={"path": ""})
@app.route('/<path:path>', methods=["GET"])
@app.route("/<path:path>", methods=["GET"])
def get_article(path):
full_url = request.url
parts = full_url.split('/',4)
parts = full_url.split("/", 4)
if len(parts) >= 5:
actual_url = 'https://' + parts[4].lstrip('/')
actual_url = "https://" + parts[4].lstrip("/")
try:
return bypass_paywall(actual_url)
except requests.exceptions.RequestException as e:
Expand All @@ -126,4 +128,4 @@ def get_article(path):
return "Invalid URL", 400


app.run(host='0.0.0.0', port=5000, debug=False)
app.run(host="0.0.0.0", port=5000, debug=False)

0 comments on commit d7260eb

Please sign in to comment.