from app import app
from app.utils.filters.markdown import md
from flask import request, abort
from werkzeug.exceptions import BadRequestKeyError
from app import csrf

class API():
    @app.route("/api/markdown", methods=["POST"])
    @csrf.exempt
    def api_markdown():
        try:
            markdown = request.get_json()['text']
        except BadRequestKeyError:
            abort(400)
        return str(md(markdown))
