diff --git a/.gitignore b/.gitignore index 11530b5..e5543ec 100644 --- a/.gitignore +++ b/.gitignore @@ -185,3 +185,5 @@ cython_debug/ gacha_game*.db gacha_game*.db.* config*.ini + +.idea \ No newline at end of file diff --git a/web/app.py b/web/app.py index f68084c..61ed38f 100644 --- a/web/app.py +++ b/web/app.py @@ -1,6 +1,8 @@ -from flask import Flask, render_template import sqlite3 +from flask import Flask, render_template, abort +from werkzeug.exceptions import HTTPException + app = Flask(__name__) DB_PATH = "./gacha_game.db" # Adjust path if needed @@ -9,6 +11,14 @@ def get_db_connection(): conn.row_factory = sqlite3.Row return conn +@app.errorhandler(HTTPException) +def handle_exception(error): + return render_template("_error.html", error=error), error.code + +@app.route("/i404") +def i404(): + return abort(404) + @app.route('/') def index(): conn = get_db_connection() @@ -33,6 +43,8 @@ def user_profile(user_id): cursor.execute('SELECT * FROM users WHERE id = ?', (user_id,)) user = cursor.fetchone() + if user is None: + abort(404) cursor.execute(''' SELECT pulls.timestamp, characters.name as character_name, characters.rarity diff --git a/web/static/style.css b/web/static/style.css new file mode 100644 index 0000000..74231c1 --- /dev/null +++ b/web/static/style.css @@ -0,0 +1,92 @@ +body { + font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; + background-color: #f4f6fa; + color: #333; + margin: 0; + padding: 0; + } + + header { + background-color: #7289da; + color: white; + padding: 20px; + text-align: center; + } + + header h1 { + margin: 0; + font-size: 2.5em; + } + + header p { + margin-top: 5px; + font-size: 1.1em; + } + + .container { + max-width: 800px; + margin: 30px auto; + padding: 20px; + background-color: #ffffff; + border-radius: 10px; + box-shadow: 0 3px 10px rgba(0, 0, 0, 0.07); + } + + h2 { + border-bottom: 1px solid #ccc; + padding-bottom: 8px; + margin-top: 30px; + } + + ul { + list-style-type: none; + padding-left: 0; + } + + li { + margin: 10px 0; + } + + a { + text-decoration: none; + color: #2c3e50; + font-weight: bold; + background-color: #e3eaf3; + padding: 8px 12px; + border-radius: 6px; + display: inline-block; + transition: background-color 0.2s; + } + + a:hover { + background-color: #cdd8e6; + } + + .leaderboard-entry { + margin-bottom: 8px; + padding: 6px 10px; + background: #f9fafc; + border-left: 4px solid #7289da; + border-radius: 5px; + } + + footer { + text-align: center; + margin-top: 40px; + font-size: 0.9em; + color: #888; + } + + .note { + background: #fcfcf0; + border: 1px dashed #bbb; + padding: 10px; + border-radius: 8px; + margin-top: 30px; + font-size: 0.95em; + color: #666; + } + + .footer-link { + margin: 0 10px; + } \ No newline at end of file diff --git a/web/templates/_base.html b/web/templates/_base.html new file mode 100644 index 0000000..a1f1b22 --- /dev/null +++ b/web/templates/_base.html @@ -0,0 +1,30 @@ + + + + + + + {% if title %} + {{ title }} + {% else %} + {% block title %}{% endblock %} + {% endif %} +  | Kemoverse + + + +
+ {% block header %}{% endblock %} +
+ +
+ {% block content %}{% endblock %} +
+ + + + diff --git a/web/templates/_error.html b/web/templates/_error.html new file mode 100644 index 0000000..defc5d8 --- /dev/null +++ b/web/templates/_error.html @@ -0,0 +1,8 @@ +{% extends "_base.html" %} +{% block title %} + {{ error.code }} +{% endblock %} +{% block content %} +

{{ error.code }} - {{ error.name }}

+

{{ error.description }}

+{% endblock %} \ No newline at end of file diff --git a/web/templates/about.html b/web/templates/about.html index 89519db..184fde9 100644 --- a/web/templates/about.html +++ b/web/templates/about.html @@ -1,13 +1,9 @@ - - - - About - Misskey Gacha Center - - +{% extends "_base.html" %} + +{% block content %}

About This Gacha

This is a playful Misskey-themed gacha tracker made with Flask and SQLite.

All rolls are stored, stats are tracked, and characters are added manually for now.

Built with love, chaos, and way too much caffeine ☕.

← Back to Home - - +{% endblock %} \ No newline at end of file diff --git a/web/templates/index.html b/web/templates/index.html index e9b1680..f9bf7a0 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -1,110 +1,11 @@ - - - - Misskey Gacha Center - - - - -
-

Misskey Gacha Center

-

Track your luck. Compare your pulls. Compete with friends.

-
- -
+{% block content %}

🎖️ Leaderboard: Most Rolls

{% for user in top_users %} @@ -125,13 +26,4 @@
🚀 This is a fun little gacha tracker! More features coming soon. Want to help shape it?
- -
- - - - - +{% endblock %} \ No newline at end of file diff --git a/web/templates/submit.html b/web/templates/submit.html index 5dc5ac9..d0424b8 100644 --- a/web/templates/submit.html +++ b/web/templates/submit.html @@ -1,12 +1,8 @@ - - - - Submit a Character - Misskey Gacha Center - - +{% extends "_base.html" %} + +{% block content %}

Submit a Character

Want to add a new character to the gacha pool?

This feature will be available soon. Stay tuned!

← Back to Home - - +{% endblock %} \ No newline at end of file diff --git a/web/templates/user.html b/web/templates/user.html index 0004052..8010538 100644 --- a/web/templates/user.html +++ b/web/templates/user.html @@ -1,57 +1,5 @@ - - - - {{ user['username'] }}'s Rolls - - - - +{% extends "_base.html" %} +{% block content %}

{{ user['username'] }}'s Gacha Rolls

User ID: {{ user['id'] }}

@@ -72,6 +20,4 @@
← Back to Users - - - +{% endblock %} \ No newline at end of file