feat: Add city domain to env
All checks were successful
Build Docker / Build Main Image (push) Successful in 18s
Build Docker / Build SLDs Image (push) Successful in 19s

This commit is contained in:
Nathan Woodburn 2023-11-09 12:59:15 +11:00
parent ec53b5862b
commit 15b62ad29e
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 14 additions and 6 deletions

18
main.py
View File

@ -20,6 +20,10 @@ dbargs = {
'database':os.getenv('DB_NAME') 'database':os.getenv('DB_NAME')
} }
CITY_DOMAIN = os.getenv('CITY_DOMAIN')
if CITY_DOMAIN == None:
CITY_DOMAIN = "exampledomainnathan1"
#Assets routes #Assets routes
@app.route('/assets/<path:path>') @app.route('/assets/<path:path>')
def assets(path): def assets(path):
@ -40,8 +44,8 @@ def index():
resp = make_response(redirect('/')) resp = make_response(redirect('/'))
resp.set_cookie('token', '', expires=0) resp.set_cookie('token', '', expires=0)
return resp return resp
return render_template('index.html',account=user['email'],account_link="account") 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") return render_template('index.html',account="Login",account_link="login",CITY_DOMAIN=CITY_DOMAIN)
@app.route('/signup', methods=['POST']) @app.route('/signup', methods=['POST'])
def signup(): def signup():
@ -77,6 +81,10 @@ def login():
@app.route('/edit') @app.route('/edit')
def edit(): def edit():
if 'token' not in request.cookies:
return redirect('/')
token = request.cookies['token'] token = request.cookies['token']
if not accounts.validate_token(token): if not accounts.validate_token(token):
return error('Invalid token') return error('Invalid token')
@ -160,17 +168,17 @@ def catch_all(path):
return resp return resp
account = user['email'] account = user['email']
account_link = "account" account_link = "account"
site = user['domain'] + ".exampledomainnathan1" site = user['domain'] + "." + CITY_DOMAIN
elif path != "signup" and path != "login": elif path != "signup" and path != "login":
return redirect('/') return redirect('/')
# If file exists, load it # If file exists, load it
if os.path.isfile('templates/' + path): if os.path.isfile('templates/' + path):
return render_template(path,account=account,account_link=account_link,site=site) return render_template(path,account=account,account_link=account_link,site=site,CITY_DOMAIN=CITY_DOMAIN)
# Try with .html # Try with .html
if os.path.isfile('templates/' + path + '.html'): if os.path.isfile('templates/' + path + '.html'):
return render_template(path + '.html',account=account,account_link=account_link,site=site) return render_template(path + '.html',account=account,account_link=account_link,site=site,CITY_DOMAIN=CITY_DOMAIN)
return redirect('/') # 404 catch all return redirect('/') # 404 catch all
# 404 catch all # 404 catch all

View File

@ -31,7 +31,7 @@
<h4 class="card-title" style="color: rgb(255,255,255);">Sign up for your free page</h4> <h4 class="card-title" style="color: rgb(255,255,255);">Sign up for your free page</h4>
</div> </div>
<form style="width: 80%;margin: auto;text-align: right;margin-top: 20px;" method="post"> <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;">.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;"> <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;">
</form> </form>
</div> </div>
</section> </section>