""" StarPunk package initialization Creates and configures the Flask application """ from flask import Flask def create_app(config=None): """ Application factory for StarPunk Args: config: Optional configuration dict to override defaults Returns: Configured Flask application instance """ app = Flask(__name__, static_folder="../static", template_folder="../templates") # Load configuration from starpunk.config import load_config load_config(app, config) # Initialize database from starpunk.database import init_db init_db(app) # Register blueprints from starpunk.routes import register_routes register_routes(app) # Error handlers @app.errorhandler(404) def not_found(error): from flask import render_template, request # Return HTML for browser requests, JSON for API requests if request.path.startswith("/api/"): return {"error": "Not found"}, 404 return render_template("404.html"), 404 @app.errorhandler(500) def server_error(error): from flask import render_template, request # Return HTML for browser requests, JSON for API requests if request.path.startswith("/api/"): return {"error": "Internal server error"}, 500 return render_template("500.html"), 500 return app # Package version (Semantic Versioning 2.0.0) # See docs/standards/versioning-strategy.md for details __version__ = "0.5.1" __version_info__ = (0, 5, 1)