Add license to webpage

This commit is contained in:
Andrew Dinh 2021-02-23 17:00:47 -08:00
parent e6db44dc17
commit 084df3e881
Signed by: andrewkdinh
GPG Key ID: 2B557D93C6C08B86
2 changed files with 29 additions and 22 deletions

46
main.py
View File

@ -26,27 +26,31 @@ app = Flask(__name__)
@app.route("/", methods=["GET", "POST"])
def index():
global POLYNOMIAL, LAST_ENDPOINT_GET, DAYS_TO_ALLOW
if request.method == "POST":
if ALIVE_PATH and DAYS_TO_ALLOW and LAST_ENDPOINT_GET and (datetime.today() - LAST_ENDPOINT_GET).days < DAYS_TO_ALLOW:
return render_template("message.html", message="Andrew is still alive. Try again another time")
captcha_id = request.form.get('captcha-id')
captcha_solution = request.form.get('captcha-solution')
v = captcha_validate(captcha_id, captcha_solution)
if not v[0]:
return render_template('message.html', message = "Failed captcha", attempts_left = v[1])
try:
coords = []
for key in request.form:
if 'x' == key[0]:
coords.append(Coordinate(int(request.form[key]), int(request.form['y' + key[1]])))
if POLYNOMIAL.valid_combination(coords):
return render_template("congrats.html", polynomial=POLYNOMIAL, domain=DOMAIN)
return render_template("message.html", message="Those points weren't valid", attempts_left = v[1])
except Exception as e:
print(e)
return render_template("message.html", message="Invalid data")
captcha = captcha_get(ttl = 300)
return render_template("index.html", polynomial = POLYNOMIAL, domain=DOMAIN, captcha_id = captcha[0], captcha_png = captcha[1])
try:
if request.method == "POST":
if ALIVE_PATH and DAYS_TO_ALLOW and LAST_ENDPOINT_GET and (datetime.today() - LAST_ENDPOINT_GET).days < DAYS_TO_ALLOW:
return render_template("message.html", message="Andrew is still alive. Try again another time")
captcha_id = request.form.get('captcha-id')
captcha_solution = request.form.get('captcha-solution')
v = captcha_validate(captcha_id, captcha_solution)
if not v[0]:
return render_template('message.html', message = "Failed captcha", attempts_left = v[1])
try:
coords = []
for key in request.form:
if 'x' == key[0]:
coords.append(Coordinate(int(request.form[key]), int(request.form['y' + key[1]])))
if POLYNOMIAL.valid_combination(coords):
return render_template("congrats.html", polynomial=POLYNOMIAL, domain=DOMAIN)
return render_template("message.html", message="Those points weren't valid", attempts_left = v[1])
except Exception as e:
print(e)
return render_template("message.html", message="Invalid data")
captcha = captcha_get(ttl = 300)
return render_template("index.html", polynomial = POLYNOMIAL, domain=DOMAIN, captcha_id = captcha[0], captcha_png = captcha[1])
except Exception as e:
print(e)
return render_template('message.html', message="Error ocurred")
@app.route("/<attempt_num>", methods=["GET", "POST"])
def attempt(attempt_num):

View File

@ -37,7 +37,7 @@
<p>Once you get the value of f(0), go to {{ domain }}/f(0)</p>
<hr />
<p>Here's resources with more information (for now, just contact info for others with a coordinate). Password should've been given to you</p>
<p>Here's resources with more information. Password should've been given to you</p>
<ul>
<li><a target="_blank" rel="noopener noreferrer" href="https://nextcloud.andrewkdinh.com/s/ADmFKLCZgdycRH8">Nextcloud</a></li>
@ -58,5 +58,8 @@
<li><a target="_blank" rel="noopener noreferrer" href="https://www.wolframalpha.com/input/?i=interpolating+polynomial+calculator">WolframAlpha</a></li>
<li><a target="_blank" rel="noopener noreferrer" href="https://planetcalc.com/8692/">PlanetCalc</a></li>
</ul>
<p>Source code available on <a target="_blank" rel="noopener noreferrer" href="https://github.com/andrewkdinh/death-code">GitHub</a> and <a target="_blank" rel="noopener noreferrer" href="https://gitea.andrewkdinh.com/andrewkdinh/death-code">Gitea</a></p>
<p>Licensed under <a target="_blank" rel="noopener noreferrer" href="https://www.gnu.org/licenses/agpl-3.0.html">AGPL 3.0</a></p>
</body>
</html>