Format files
This commit is contained in:
+7
-4
@@ -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")
|
||||
@@ -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)
|
||||
@@ -55,4 +57,5 @@ def get_article(path):
|
||||
else:
|
||||
return "Invalid URL", 400
|
||||
|
||||
|
||||
app.run(debug=False)
|
||||
|
||||
Reference in New Issue
Block a user