67 lines
2.4 KiB
Python
67 lines
2.4 KiB
Python
"""
|
|
Configuration Blueprint
|
|
Provides configuration information and environment variables endpoints.
|
|
"""
|
|
|
|
import os
|
|
from flask import Blueprint
|
|
|
|
from ..app import Config
|
|
from ..shared import _format_response, log_performance, logger
|
|
|
|
# Create blueprint
|
|
config_bp = Blueprint('config', __name__, url_prefix='/config')
|
|
|
|
|
|
@config_bp.route('', methods=['GET'])
|
|
@log_performance
|
|
def get_config():
|
|
"""Get current configuration (without sensitive information)."""
|
|
logger.debug("Configuration requested")
|
|
|
|
try:
|
|
config_info = Config.to_dict()
|
|
|
|
# Remove potentially sensitive information
|
|
safe_config = config_info.copy()
|
|
|
|
data = {
|
|
"configuration": safe_config,
|
|
"environment_variables": {
|
|
"supported": [
|
|
"GASFLUX_HOST",
|
|
"GASFLUX_PORT",
|
|
"GASFLUX_DEBUG",
|
|
"GASFLUX_UPLOAD_FOLDER",
|
|
"GASFLUX_OUTPUT_FOLDER",
|
|
"GASFLUX_MAX_CONTENT_LENGTH",
|
|
"GASFLUX_LOG_LEVEL",
|
|
"GASFLUX_LOG_FILE",
|
|
"GASFLUX_CORS_ORIGINS",
|
|
"GASFLUX_TASK_CLEANUP_INTERVAL",
|
|
"GASFLUX_MAX_TASK_AGE",
|
|
"GASFLUX_THREADS",
|
|
"GASFLUX_CONNECTION_LIMIT",
|
|
"GASFLUX_CHANNEL_TIMEOUT"
|
|
],
|
|
"current_values": {
|
|
key: os.getenv(key, "not set") if key.startswith("GASFLUX_") else "internal"
|
|
for key in [
|
|
"GASFLUX_HOST", "GASFLUX_PORT", "GASFLUX_DEBUG",
|
|
"GASFLUX_UPLOAD_FOLDER", "GASFLUX_OUTPUT_FOLDER",
|
|
"GASFLUX_MAX_CONTENT_LENGTH", "GASFLUX_LOG_LEVEL",
|
|
"GASFLUX_LOG_FILE", "GASFLUX_CORS_ORIGINS",
|
|
"GASFLUX_TASK_CLEANUP_INTERVAL", "GASFLUX_MAX_TASK_AGE",
|
|
"GASFLUX_THREADS", "GASFLUX_CONNECTION_LIMIT",
|
|
"GASFLUX_CHANNEL_TIMEOUT"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
return _format_response(200, "配置信息获取成功", data)
|
|
|
|
except Exception as e:
|
|
logger.error(f"Failed to retrieve configuration: {str(e)}", exc_info=True)
|
|
return _format_response(500, "获取配置信息失败", {
|
|
"error_details": str(e)
|
|
}) |