wysiwyg-editor-python-sdk icon indicating copy to clipboard operation
wysiwyg-editor-python-sdk copied to clipboard

upload image cannot be loaded from passed link in python sdk for flask

Open ghost opened this issue 4 years ago • 0 comments

Hi, I am using froala's python sdk for my flask app. It uploads the image successfully but can't load the image. Here is my code:

@app.route('/upload_image', methods=['POST','GET'])
def upload_image():
    try:
        response = Image.upload(FlaskAdapter(request), '\\public\\')
    except Exception:
        response = {'error': str(sys.exc_info()[1])}
    return json.dumps(response)


@app.route('/load')
def load():
    try:
        response = Image.list('public/')
    except:
        response = {'error': str(sys.exc_info()[1])}
    return json.dumps(response)

Here is the html code:

<form action="/" method="POST">
        <textarea name="editor" class="form-control selector"></textarea>
        <input type="submit" value="Submit">
    </form>
    <script type="text/javascript" src="static/froala-editor/js/froala_editor.pkgd.min.js"></script>
    <script type="text/javascript" src="static/froala-editor/js/plugins/image_manager.min.js"></script>
    <script>
        new FroalaEditor('.selector', {
          // Set the image upload URL.
          imageUploadURL: '/upload_image',
          imageManagerLoadUrl:'/load',
        })
        
      </script>

The image says 404 while loading:

127.0.0.1 - - [21/Apr/2021 10:28:35] "POST /upload_image HTTP/1.1" 200 -
127.0.0.1 - - [21/Apr/2021 10:28:35] "GET /public/1a7a6e5e85028030c2e9457532bc691bc5843701.jpg HTTP/1.1" 404 -

ghost avatar Apr 21 '21 04:04 ghost