显小效果:
前端代码配置:
{% block script %}
{{ super() }}
{{ ckeditor.load() }}
{{ ckeditor.config(name='article') }}
{% endblock %}
后端代码:
@user_bp.route("/upload",methods=["POST"])
def upload():
f = request.files.get("upload")
filename = f.filename
extension = filename.split(".")[1].lower()
if extension not in ['jpg', 'gif', 'png', 'jpeg']:
return upload_fail("图片格式不支持")
f.save(os.path.join("/upload/photo",filename))
url = url_for("uploaded_files",filename=filename)
return upload_success(url,filename=filename)
@user_bp.route("/uploaded-files/<filename>")
def uploaded_files(filename):
path = "/upload/photo"
return send_from_directory(directory=path,filename=filename)
配置:
CKEDITOR_HEIGHT = "500px"
CKEDITOR_WIDTH = "400px"
CKEDITOR_FILE_UPLOADER = "user.upload"