mirror of
https://github.com/csd4ni3l/grass_touching_captcha.git
synced 2026-01-01 04:23:45 +01:00
add new fields to user so we can track grass touching activity later, add part of the application part which currently includes a homepage and a leaderboard
This commit is contained in:
37
main.py
37
main.py
@@ -24,6 +24,9 @@ def get_db():
|
|||||||
db.execute("""
|
db.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS Users (
|
CREATE TABLE IF NOT EXISTS Users (
|
||||||
username TEXT PRIMARY KEY,
|
username TEXT PRIMARY KEY,
|
||||||
|
last_grass_touch_time TEXT NOT NULL,
|
||||||
|
grass_touching_count INT NOT NULL,
|
||||||
|
banned BOOL,
|
||||||
password TEXT NOT NULL,
|
password TEXT NOT NULL,
|
||||||
password_salt TEXT NOT NULL
|
password_salt TEXT NOT NULL
|
||||||
)
|
)
|
||||||
@@ -53,10 +56,30 @@ def user_loader(user_id):
|
|||||||
user.id = user_id
|
user.id = user_id
|
||||||
return user
|
return user
|
||||||
|
|
||||||
@app.route("/iamarealpersonwhotouchedgrass")
|
@app.route("/app")
|
||||||
@flask_login.login_required
|
@flask_login.login_required
|
||||||
def iamarealpersonwhotouchedgrass():
|
def application():
|
||||||
return "You are a real person who touched grass! I can't believe this. You probably just tricked the AI or smth..."
|
username = flask_login.current_user.id
|
||||||
|
|
||||||
|
return render_template("app.jinja2", username=username)
|
||||||
|
|
||||||
|
@app.route("/leaderboard")
|
||||||
|
@flask_login.login_required
|
||||||
|
def leaderboard():
|
||||||
|
username = flask_login.current_user.id
|
||||||
|
|
||||||
|
cur = get_db().cursor()
|
||||||
|
|
||||||
|
cur.execute("SELECT grass_touching_count, username FROM USERS ORDER BY grass_touching_count DESC, username ASC LIMIT 25")
|
||||||
|
|
||||||
|
users = cur.fetchall()
|
||||||
|
if not users:
|
||||||
|
cur.close()
|
||||||
|
return Response("DB is not healthy.", 401)
|
||||||
|
|
||||||
|
cur.close()
|
||||||
|
|
||||||
|
return render_template("leaderboard.jinja2", users=users, current_username=username)
|
||||||
|
|
||||||
@app.route("/login", methods=["GET", "POST"])
|
@app.route("/login", methods=["GET", "POST"])
|
||||||
def login():
|
def login():
|
||||||
@@ -83,7 +106,7 @@ def login():
|
|||||||
user.id = username
|
user.id = username
|
||||||
flask_login.login_user(user, remember=True)
|
flask_login.login_user(user, remember=True)
|
||||||
|
|
||||||
return redirect(url_for("iamarealpersonwhotouchedgrass"))
|
return redirect(url_for("application"))
|
||||||
else:
|
else:
|
||||||
cur.close()
|
cur.close()
|
||||||
return Response("Unathorized access. Just go outside, touch grass and make your own account...", 401)
|
return Response("Unathorized access. Just go outside, touch grass and make your own account...", 401)
|
||||||
@@ -112,7 +135,7 @@ def register():
|
|||||||
user.id = username
|
user.id = username
|
||||||
flask_login.login_user(user, remember=True)
|
flask_login.login_user(user, remember=True)
|
||||||
|
|
||||||
return redirect(url_for("iamarealpersonwhotouchedgrass"))
|
return redirect(url_for("application"))
|
||||||
|
|
||||||
def resize_image_file(path, max_side=256, fmt="JPEG"):
|
def resize_image_file(path, max_side=256, fmt="JPEG"):
|
||||||
img = Image.open(path)
|
img = Image.open(path)
|
||||||
@@ -175,7 +198,7 @@ def info():
|
|||||||
@app.route("/")
|
@app.route("/")
|
||||||
def main():
|
def main():
|
||||||
if flask_login.current_user.is_authenticated:
|
if flask_login.current_user.is_authenticated:
|
||||||
return redirect(url_for("iamarealpersonwhotouchedgrass"))
|
return redirect(url_for("application"))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for("login"))
|
return redirect(url_for("login"))
|
||||||
|
|
||||||
@@ -188,4 +211,4 @@ def logout():
|
|||||||
def unauthorized_handler():
|
def unauthorized_handler():
|
||||||
return redirect("/login")
|
return redirect("/login")
|
||||||
|
|
||||||
app.run(port=os.environ.get("PORT"), host=os.environ.get("HOST", "0.0.0.0"))
|
app.run(debug=True, port=os.environ.get("PORT"), host=os.environ.get("HOST", "0.0.0.0"))
|
||||||
44
templates/app.jinja2
Normal file
44
templates/app.jinja2
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
{% extends "base.jinja2" %}
|
||||||
|
{% block title %}Grass Touching Dashboard{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
|
<div class="container-fluid d-flex justify-content-center">
|
||||||
|
<a class="navbar-brand" href="#">Grass Touching Captcha</a>
|
||||||
|
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/info">Information</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/leaderboard">Leaderboard</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-center align-items-center vh-100 bg-dark">
|
||||||
|
<div class="d-flex flex-column justify-content-center text-white text-center" style="transform: translateY(-25%);">
|
||||||
|
<h1>Welcome back, {{ username }}</h1>
|
||||||
|
<h5>Why are you here?</h5>
|
||||||
|
<h5>Why did you cheat?</h5>
|
||||||
|
<h5>I know you did!!!</h5>
|
||||||
|
<h5>No one touches grass!</h5>
|
||||||
|
<h5>I know you don't go outside you liar!</h5>
|
||||||
|
<h5>You are a discord moderator who plays League of Legends 24 hours a day!</h5>
|
||||||
|
<h5>But, if you really want to learn how to go outside and touch grass, check our <a href="/info">unofficial guide</a></h5>
|
||||||
|
<h5>To prove you belong here, you have to touch grass each day or your account will be permanently banned with no exceptions.</h5>
|
||||||
|
<h5>To see how you fare against others, check the <a href="/leaderboard">leaderboard</a></h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
36
templates/leaderboard.jinja2
Normal file
36
templates/leaderboard.jinja2
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{% extends "base.jinja2" %}
|
||||||
|
{% block title %}Grass Touching Leaderboard{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
|
<div class="container-fluid d-flex justify-content-center">
|
||||||
|
<a class="navbar-brand" href="#">Grass Touching Captcha</a>
|
||||||
|
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/app">Home</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/info">Information</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link active" aria-current="page" href="/leaderboard">Leaderboard</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div class="d-flex justify-content-center align-items-center vh-100 bg-dark">
|
||||||
|
<h1>Leaderboard</h1>
|
||||||
|
<ul class="list-group">
|
||||||
|
{% for user in users %}
|
||||||
|
<li class="list-group-item {% if user.1 == current_username %}active{% endif %}">{{ user.0 }} - {{ user.1 }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endblock%}
|
||||||
Reference in New Issue
Block a user