Phase 5 adds RSS feed generation and production containerization. This is a minor version bump per semantic versioning. Related: docs/decisions/ADR-015-phase-5-implementation-approach.md
62 lines
1.5 KiB
Python
62 lines
1.5 KiB
Python
"""
|
|
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.6.0"
|
|
__version_info__ = (0, 6, 0)
|