log impl
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
from flask import Blueprint, request, jsonify
|
||||
from db import get_db
|
||||
from db.models.Markdown import Markdown
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
markdown_bp = Blueprint('markdown', __name__, url_prefix='/api/markdown')
|
||||
|
||||
@@ -23,9 +25,14 @@ def create_markdown():
|
||||
return jsonify({"error": "missing required fields"}), 400
|
||||
new_markdown = Markdown(title=title, content=content, path=path)
|
||||
with get_db() as db:
|
||||
db.add(new_markdown)
|
||||
db.commit()
|
||||
return jsonify(new_markdown.to_dict()), 201
|
||||
try:
|
||||
db.add(new_markdown)
|
||||
db.commit()
|
||||
return jsonify(new_markdown.to_dict()), 201
|
||||
except Exception as e:
|
||||
logger.error(f"failed to create markdown: {e}")
|
||||
db.rollback()
|
||||
return jsonify({"error": "create failed"}), 500
|
||||
|
||||
@markdown_bp.route('/<int:markdown_id>', methods=['PUT'])
|
||||
def update_markdown(markdown_id):
|
||||
|
||||
Reference in New Issue
Block a user