2023-11-08 20:56:03 +11:00
|
|
|
from flask import Flask, make_response, redirect, render_template_string, request, jsonify, render_template, send_from_directory
|
2023-11-08 22:51:39 +11:00
|
|
|
from bs4 import BeautifulSoup
|
2023-11-09 12:51:35 +11:00
|
|
|
import os
|
|
|
|
import dotenv
|
|
|
|
|
|
|
|
main_domain = "cities.hnshosting.au"
|
|
|
|
if os.getenv('MAIN_DOMAIN') != None:
|
|
|
|
main_domain = os.getenv('MAIN_DOMAIN')
|
2023-11-08 20:56:03 +11:00
|
|
|
|
|
|
|
def render(data):
|
2023-11-08 22:32:00 +11:00
|
|
|
if data == "":
|
2023-11-09 12:51:35 +11:00
|
|
|
return redirect("https://" + main_domain + '/claim?domain=' + request.host.split('.')[0])
|
2023-11-08 22:32:00 +11:00
|
|
|
|
2023-11-08 22:51:39 +11:00
|
|
|
try:
|
|
|
|
soup = BeautifulSoup(data, 'html.parser')
|
|
|
|
for script in soup.find_all('script'):
|
|
|
|
script.extract()
|
2023-11-08 23:25:01 +11:00
|
|
|
|
|
|
|
modified = str(soup)
|
2023-11-08 23:27:20 +11:00
|
|
|
return render_template_string(modified)
|
2023-11-08 22:51:39 +11:00
|
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
return "<h1>Invalid HTML</h1><br>" + str(e)
|