Feat: Multiplayer sessions added using CRUD database.

This commit is contained in:
2026-02-10 11:49:38 +00:00
parent bbbd21d4ad
commit fa81fddbd4
6850 changed files with 808827 additions and 8 deletions

11
helpers/__init__.py Normal file
View File

@@ -0,0 +1,11 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Module Initialisation
Feature: Helpers
Description:
Initialises helpers module.
"""

43
helpers/helper_app.py Normal file
View File

@@ -0,0 +1,43 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Helpers
Feature: App Helper
"""
# internal
# external
from pydantic import BaseModel, ConfigDict
from flask import current_app
# from flask_sqlalchemy import SQLAlchemy
class Helper_App(BaseModel):
@staticmethod
def get_request_data(request):
Helper_App.console_log(f'request={request}')
data = {}
try:
data = request.json
except:
try:
data = request.data
except:
try:
data = request.form
except:
pass
Helper_App.console_log(f'data={data}')
return data
@staticmethod
def console_log(message):
if current_app.app_config.is_development:
print(message)
elif current_app.app_config.is_production:
pass
current_app.logger.info(message)

42
helpers/helper_db_sql.py Normal file
View File

@@ -0,0 +1,42 @@
"""
Project: PARTS Website
Author: Edward Middleton-Smith
Precision And Research Technology Systems Limited
Technology: Helpers
Feature: MySQL Database Helper
Notes: This architecture does not work with Flask-SQLAlchemy - db connection must be initialised with Flask app initialisation
"""
# internal
# external
from pydantic import BaseModel, ConfigDict
from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session
from flask_sqlalchemy import SQLAlchemy
import uuid
class Helper_DB_SQL(BaseModel):
app: Flask
model_config = ConfigDict(arbitrary_types_allowed=True)
def __init__(self, app):
super().__init__(app=app)
# self.app = app
def get_db_connection(self):
db = SQLAlchemy()
db.init_app(self.app)
with self.app.app_context():
db.create_all()
db.engine.url = self.app.config['SQLALCHEMY_DATABASE_URI']
return db
@staticmethod
def create_guid_str():
return str(uuid.uuid4())
@staticmethod
def create_guid():
return str(uuid.uuid4())