mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-07-04 13:06:20 +00:00
Add profile picture uploading
This commit is contained in:
parent
361d76f530
commit
fdac4dc402
8 changed files with 73 additions and 22 deletions
|
@ -1,9 +1,10 @@
|
|||
import re
|
||||
import shortuuid
|
||||
|
||||
from flask import Blueprint, request, jsonify
|
||||
from flask import Blueprint, request, jsonify, send_from_directory
|
||||
from flask_login import login_required, current_user
|
||||
from werkzeug.security import check_password_hash
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from .models import Scores, Sessions, Users
|
||||
from .extensions import db
|
||||
|
@ -11,12 +12,19 @@ from .config import (
|
|||
GAME_DIFFICULTIES,
|
||||
MAX_SEARCH_RESULTS,
|
||||
USER_REGEX,
|
||||
UPLOAD_DIR,
|
||||
)
|
||||
|
||||
|
||||
blueprint = Blueprint("api", __name__, url_prefix="/api")
|
||||
|
||||
|
||||
@blueprint.route("/uploads/<filename>", methods=["GET"])
|
||||
def upload_dir(filename):
|
||||
filename = secure_filename(filename)
|
||||
return send_from_directory(UPLOAD_DIR, filename)
|
||||
|
||||
|
||||
@blueprint.route("/tokens", methods=["POST"])
|
||||
@login_required
|
||||
def tokens():
|
||||
|
@ -58,6 +66,10 @@ def post():
|
|||
|
||||
if int(difficulty) not in GAME_DIFFICULTIES:
|
||||
return "Invalid difficulty!"
|
||||
# This is a fix for a bug in the game that we dunno how to actually fix
|
||||
# Yupeeeeeeeeee
|
||||
if score < 10:
|
||||
return "Score is impossible!"
|
||||
|
||||
session_data = Sessions.query.filter_by(auth_key=session_key).first()
|
||||
if not session_data:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue