57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
"""
|
|
StarPunk package initialization
|
|
Creates and configures the Flask application
|
|
"""
|
|
|
|
from flask import Flask
|
|
from pathlib import Path
|
|
|
|
|
|
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
|
|
# TODO: Implement blueprints in separate modules
|
|
# from starpunk.routes import public, admin, api
|
|
# app.register_blueprint(public.bp)
|
|
# app.register_blueprint(admin.bp)
|
|
# app.register_blueprint(api.bp)
|
|
|
|
# Error handlers
|
|
@app.errorhandler(404)
|
|
def not_found(error):
|
|
return {'error': 'Not found'}, 404
|
|
|
|
@app.errorhandler(500)
|
|
def server_error(error):
|
|
return {'error': 'Internal server error'}, 500
|
|
|
|
return app
|
|
|
|
|
|
# Package version (Semantic Versioning 2.0.0)
|
|
# See docs/standards/versioning-strategy.md for details
|
|
__version__ = "0.3.0"
|
|
__version_info__ = (0, 3, 0)
|