Source code for app.landing

from utils.logging import logger
import os
import uuid
from tinydb import TinyDB, Query
import functools
import random
import json


from flask_limiter.util import get_remote_address
from flask import (
    Blueprint, flash, g, redirect, render_template, request, session, url_for, jsonify, make_response
)

# local imports
from app import socketio, limiter

base_dir = os.path.dirname(os.path.abspath(__file__))

# db
db_uuid_file = os.path.join(base_dir, "../db/uuids.json")
db = TinyDB(db_uuid_file)

UUID = Query()

# blueprints
bp = Blueprint('landing', __name__)

# send user to front
[docs] @bp.route('/') @limiter.limit("5 per minute") def redirect_front(): """ Funksjon for å redirigere trafikk til landingssiden (front). :rute: GET / :return: Rediriger nettleseren til /front-endepunktet. """ return redirect(url_for('front.front'))
@bp.route('/another_test', methods=['GET']) def another_test(): """ Kun for testing. """ try: socketio.emit("another_event", {"data": "from landing.py"}) logger.info("another event landing.py") return jsonify({"status": "success"}), 200 except Exception as e: logger.error(f"failed landing.py: {e}") return jsonify({"status": "error", "error": str(e)}), 500