Vitalis_Devcore / api /app.py
FerrellSyntheticIntelligence
Add understanding engine, conversation interface, meditation engine, unified launcher
7d9e142
import os
from flask import Flask, jsonify
from flask_cors import CORS
from extensions import db
from auth import auth_bp
def create_app(config: dict = None) -> Flask:
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv(
"DATABASE_URL", "sqlite:///vitalis.db"
)
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config["SECRET_KEY"] = os.getenv("SECRET_KEY", "dev-secret-change-me")
if config:
app.config.update(config)
CORS(app, resources={r"/api/*": {"origins": "*"}})
db.init_app(app)
# Register blueprints
app.register_blueprint(auth_bp)
@app.errorhandler(404)
def not_found(e):
return jsonify({"error": "Not found"}), 404
@app.errorhandler(500)
def server_error(e):
return jsonify({"error": "Internal server error"}), 500
@app.get("/health")
def health():
return jsonify({"status": "ok", "service": "vitalis-api"})
with app.app_context():
db.create_all()
return app
if __name__ == "__main__":
app = create_app()
app.run(debug=os.getenv("FLASK_DEBUG", "1") == "1", port=5000)