Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Nahid180 opened this issue Apr 21, 2021 · 0 comments
Open

Comments

@Nahid180
Copy link

Nahid180 commented Apr 21, 2021

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 -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant