training fix. add global settings

This commit is contained in:
2025-12-02 09:31:52 +01:00
parent 55b1b2b5fe
commit c3c7e042bb
86 changed files with 77512 additions and 7054 deletions

View File

@@ -1,43 +1,48 @@
from flask import Flask, send_from_directory
from flask_cors import CORS
import os
from database.database import db, init_db
app = Flask(__name__, static_folder='..', static_url_path='')
CORS(app)
# Configure database
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:root@localhost/myapp'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
# Initialize database
db.init_app(app)
# Import and register blueprints
from routes.api import api_bp
app.register_blueprint(api_bp, url_prefix='/api')
# Serve static files (HTML, CSS, JS)
@app.route('/')
def index():
return send_from_directory('..', 'index.html')
@app.route('/<path:path>')
def serve_static(path):
return send_from_directory('..', path)
# Initialize DB and start server
if __name__ == '__main__':
with app.app_context():
try:
# Test database connection
db.engine.connect()
print('DB connection established.')
# Create tables if they don't exist
db.create_all()
# Start server
app.run(host='0.0.0.0', port=3000, debug=True)
except Exception as err:
print(f'Failed to start: {err}')
from flask import Flask, send_from_directory
from flask_cors import CORS
import os
from database.database import db, init_db
app = Flask(__name__, static_folder='..', static_url_path='')
CORS(app)
# Configure database
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:root@localhost/myapp2'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
# Initialize database
db.init_app(app)
# Import and register blueprints
from routes.api import api_bp
app.register_blueprint(api_bp, url_prefix='/api')
# Serve static files (HTML, CSS, JS)
@app.route('/')
def index():
return send_from_directory('..', 'index.html')
@app.route('/<path:path>')
def serve_static(path):
return send_from_directory('..', path)
# Initialize DB and start server
if __name__ == '__main__':
with app.app_context():
try:
# Test database connection
db.engine.connect()
print('DB connection established.')
# Create tables if they don't exist
db.create_all()
# Initialize default settings
from services.settings_service import initialize_default_settings
initialize_default_settings()
print('Settings initialized.')
# Start server
app.run(host='0.0.0.0', port=4000, debug=True)
except Exception as err:
print(f'Failed to start: {err}')