Add license to webpage
This commit is contained in:
parent
e6db44dc17
commit
084df3e881
46
main.py
46
main.py
|
@ -26,27 +26,31 @@ app = Flask(__name__)
|
||||||
@app.route("/", methods=["GET", "POST"])
|
@app.route("/", methods=["GET", "POST"])
|
||||||
def index():
|
def index():
|
||||||
global POLYNOMIAL, LAST_ENDPOINT_GET, DAYS_TO_ALLOW
|
global POLYNOMIAL, LAST_ENDPOINT_GET, DAYS_TO_ALLOW
|
||||||
if request.method == "POST":
|
try:
|
||||||
if ALIVE_PATH and DAYS_TO_ALLOW and LAST_ENDPOINT_GET and (datetime.today() - LAST_ENDPOINT_GET).days < DAYS_TO_ALLOW:
|
if request.method == "POST":
|
||||||
return render_template("message.html", message="Andrew is still alive. Try again another time")
|
if ALIVE_PATH and DAYS_TO_ALLOW and LAST_ENDPOINT_GET and (datetime.today() - LAST_ENDPOINT_GET).days < DAYS_TO_ALLOW:
|
||||||
captcha_id = request.form.get('captcha-id')
|
return render_template("message.html", message="Andrew is still alive. Try again another time")
|
||||||
captcha_solution = request.form.get('captcha-solution')
|
captcha_id = request.form.get('captcha-id')
|
||||||
v = captcha_validate(captcha_id, captcha_solution)
|
captcha_solution = request.form.get('captcha-solution')
|
||||||
if not v[0]:
|
v = captcha_validate(captcha_id, captcha_solution)
|
||||||
return render_template('message.html', message = "Failed captcha", attempts_left = v[1])
|
if not v[0]:
|
||||||
try:
|
return render_template('message.html', message = "Failed captcha", attempts_left = v[1])
|
||||||
coords = []
|
try:
|
||||||
for key in request.form:
|
coords = []
|
||||||
if 'x' == key[0]:
|
for key in request.form:
|
||||||
coords.append(Coordinate(int(request.form[key]), int(request.form['y' + key[1]])))
|
if 'x' == key[0]:
|
||||||
if POLYNOMIAL.valid_combination(coords):
|
coords.append(Coordinate(int(request.form[key]), int(request.form['y' + key[1]])))
|
||||||
return render_template("congrats.html", polynomial=POLYNOMIAL, domain=DOMAIN)
|
if POLYNOMIAL.valid_combination(coords):
|
||||||
return render_template("message.html", message="Those points weren't valid", attempts_left = v[1])
|
return render_template("congrats.html", polynomial=POLYNOMIAL, domain=DOMAIN)
|
||||||
except Exception as e:
|
return render_template("message.html", message="Those points weren't valid", attempts_left = v[1])
|
||||||
print(e)
|
except Exception as e:
|
||||||
return render_template("message.html", message="Invalid data")
|
print(e)
|
||||||
captcha = captcha_get(ttl = 300)
|
return render_template("message.html", message="Invalid data")
|
||||||
return render_template("index.html", polynomial = POLYNOMIAL, domain=DOMAIN, captcha_id = captcha[0], captcha_png = captcha[1])
|
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"])
|
@app.route("/<attempt_num>", methods=["GET", "POST"])
|
||||||
def attempt(attempt_num):
|
def attempt(attempt_num):
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<p>Once you get the value of f(0), go to {{ domain }}/f(0)</p>
|
<p>Once you get the value of f(0), go to {{ domain }}/f(0)</p>
|
||||||
|
|
||||||
<hr />
|
<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>
|
<ul>
|
||||||
<li><a target="_blank" rel="noopener noreferrer" href="https://nextcloud.andrewkdinh.com/s/ADmFKLCZgdycRH8">Nextcloud</a></li>
|
<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://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>
|
<li><a target="_blank" rel="noopener noreferrer" href="https://planetcalc.com/8692/">PlanetCalc</a></li>
|
||||||
</ul>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue