38 lines
721 B
Python
38 lines
721 B
Python
from flask import Blueprint, jsonify, request
|
|
from flask.helpers import get_env
|
|
|
|
from config import get_config, write_config, load_config
|
|
|
|
blueprint = Blueprint("api_config", __name__, url_prefix="/api/config")
|
|
|
|
|
|
@blueprint.get("/")
|
|
def get_global_config():
|
|
return jsonify(get_config())
|
|
|
|
|
|
@blueprint.get("/env")
|
|
def get_current_env():
|
|
return jsonify({
|
|
"prod": get_env() == "production"
|
|
})
|
|
|
|
|
|
@blueprint.put("/")
|
|
def modify_global_config():
|
|
return jsonify(request.json)
|
|
|
|
|
|
@blueprint.post("/write")
|
|
def write_global_config():
|
|
return jsonify({
|
|
"result": write_config()
|
|
})
|
|
|
|
|
|
@blueprint.post("/load")
|
|
def load_global_config():
|
|
return jsonify({
|
|
"result": load_config()
|
|
})
|