Compare commits
No commits in common. "15b62ad29ee4e90f7a019396d2f37e44c151f4c0" and "114818f294a4c6f247675653f69da4a67e4a40a5" have entirely different histories.
15b62ad29e
...
114818f294
@ -21,7 +21,6 @@ services:
|
||||
DB_USER: main
|
||||
DB_PASSWORD: your-db-password
|
||||
DB_NAME: main
|
||||
CITY_DOMAIN: exampledomainnathan1
|
||||
WORKERS: 2 # number of workers to run (should be 2 * number of cores)
|
||||
|
||||
sites:
|
||||
@ -33,7 +32,6 @@ services:
|
||||
DB_USER: main
|
||||
DB_PASSWORD: your-db-password
|
||||
DB_NAME: main
|
||||
MAIN_DOMAIN: cities.hnshosting.au
|
||||
WORKERS: 2 # number of workers to run (should be 2 * number of cores)
|
||||
|
||||
db:
|
||||
|
18
main.py
18
main.py
@ -20,10 +20,6 @@ dbargs = {
|
||||
'database':os.getenv('DB_NAME')
|
||||
}
|
||||
|
||||
CITY_DOMAIN = os.getenv('CITY_DOMAIN')
|
||||
if CITY_DOMAIN == None:
|
||||
CITY_DOMAIN = "exampledomainnathan1"
|
||||
|
||||
#Assets routes
|
||||
@app.route('/assets/<path:path>')
|
||||
def assets(path):
|
||||
@ -44,8 +40,8 @@ def index():
|
||||
resp = make_response(redirect('/'))
|
||||
resp.set_cookie('token', '', expires=0)
|
||||
return resp
|
||||
return render_template('index.html',account=user['email'],account_link="account",CITY_DOMAIN=CITY_DOMAIN)
|
||||
return render_template('index.html',account="Login",account_link="login",CITY_DOMAIN=CITY_DOMAIN)
|
||||
return render_template('index.html',account=user['email'],account_link="account")
|
||||
return render_template('index.html',account="Login",account_link="login")
|
||||
|
||||
@app.route('/signup', methods=['POST'])
|
||||
def signup():
|
||||
@ -81,10 +77,6 @@ def login():
|
||||
|
||||
@app.route('/edit')
|
||||
def edit():
|
||||
|
||||
if 'token' not in request.cookies:
|
||||
return redirect('/')
|
||||
|
||||
token = request.cookies['token']
|
||||
if not accounts.validate_token(token):
|
||||
return error('Invalid token')
|
||||
@ -168,17 +160,17 @@ def catch_all(path):
|
||||
return resp
|
||||
account = user['email']
|
||||
account_link = "account"
|
||||
site = user['domain'] + "." + CITY_DOMAIN
|
||||
site = user['domain'] + ".exampledomainnathan1"
|
||||
elif path != "signup" and path != "login":
|
||||
return redirect('/')
|
||||
|
||||
# If file exists, load it
|
||||
if os.path.isfile('templates/' + path):
|
||||
return render_template(path,account=account,account_link=account_link,site=site,CITY_DOMAIN=CITY_DOMAIN)
|
||||
return render_template(path,account=account,account_link=account_link,site=site)
|
||||
|
||||
# Try with .html
|
||||
if os.path.isfile('templates/' + path + '.html'):
|
||||
return render_template(path + '.html',account=account,account_link=account_link,site=site,CITY_DOMAIN=CITY_DOMAIN)
|
||||
return render_template(path + '.html',account=account,account_link=account_link,site=site)
|
||||
return redirect('/') # 404 catch all
|
||||
|
||||
# 404 catch all
|
||||
|
@ -24,7 +24,7 @@ def get_website_data(domain):
|
||||
connection.close()
|
||||
|
||||
if data == []:
|
||||
return ""
|
||||
return "No data found for this domain"
|
||||
|
||||
parsed = data[0][2]
|
||||
parsed = json.loads(parsed)
|
||||
|
@ -12,20 +12,21 @@ import website
|
||||
app = Flask(__name__)
|
||||
dotenv.load_dotenv()
|
||||
|
||||
main_domain = "cities.hnshosting.au"
|
||||
if os.getenv('MAIN_DOMAIN') != None:
|
||||
main_domain = os.getenv('MAIN_DOMAIN')
|
||||
|
||||
#Assets routes
|
||||
@app.route('/assets/<path:path>')
|
||||
def assets(path):
|
||||
return send_from_directory('templates/assets', path)
|
||||
|
||||
#! TODO make prettier
|
||||
def error(message):
|
||||
return jsonify({'success': False, 'message': message}), 400
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
host = request.host
|
||||
if len(host.split('.')) != 2:
|
||||
return redirect('https://'+main_domain)
|
||||
return error('Invalid domain')
|
||||
host = host.split('.')[0]
|
||||
|
||||
# Get website data
|
||||
|
@ -1,15 +1,9 @@
|
||||
from flask import Flask, make_response, redirect, render_template_string, request, jsonify, render_template, send_from_directory
|
||||
from bs4 import BeautifulSoup
|
||||
import os
|
||||
import dotenv
|
||||
|
||||
main_domain = "cities.hnshosting.au"
|
||||
if os.getenv('MAIN_DOMAIN') != None:
|
||||
main_domain = os.getenv('MAIN_DOMAIN')
|
||||
|
||||
def render(data):
|
||||
if data == "":
|
||||
return redirect("https://" + main_domain + '/claim?domain=' + request.host.split('.')[0])
|
||||
return "No data found for this domain"
|
||||
|
||||
try:
|
||||
soup = BeautifulSoup(data, 'html.parser')
|
||||
|
@ -31,7 +31,7 @@
|
||||
<h4 class="card-title" style="color: rgb(255,255,255);">Sign up for your free page</h4>
|
||||
</div>
|
||||
<form style="width: 80%;margin: auto;text-align: right;margin-top: 20px;" method="post">
|
||||
<p class="tld" style="position: relative;display: inline;color: rgb(0,0,0);margin-right: 10px;">.{{CITY_DOMAIN}}</p><input class="form-control" type="text" id="domain" style="margin: auto;width: 100%;margin-top: -30px;" placeholder="yourname" name="domain" required=""><input class="form-control" type="email" style="margin: auto;width: 100%;margin-top: 10px;" placeholder="email" name="email" required=""><input class="form-control" type="password" style="margin: auto;width: 100%;margin-top: 10px;" name="password" placeholder="Password" required="" minlength="6"><input class="btn btn-primary" type="submit" style="margin-top: 10px;">
|
||||
<p class="tld" style="position: relative;display: inline;color: rgb(0,0,0);margin-right: 10px;">.exampledomainnathan1</p><input class="form-control" type="text" id="domain" style="margin: auto;width: 100%;margin-top: -30px;" placeholder="yourname" name="domain" required=""><input class="form-control" type="email" style="margin: auto;width: 100%;margin-top: 10px;" placeholder="email" name="email" required=""><input class="form-control" type="password" style="margin: auto;width: 100%;margin-top: 10px;" name="password" placeholder="Password" required="" minlength="6"><input class="btn btn-primary" type="submit" style="margin-top: 10px;">
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
Loading…
Reference in New Issue
Block a user