flask get summernote text

<form action="/updateTest" method="POST">
 <h1 style="text-align:center">content</h1><textarea name=content id="summernote">{{value}</textarea>
 <input class="input-btn" type="submit" value="Update">

0
0
Phoenix Logan 186120 points

                                    &lt;style&gt;
$(document).ready(function() {
        $('#summernote').summernote({
            height: 300,
            focus: true,
            callbacks: {
                onImageUpload(files) {
                  sendFile(files[0], data =&gt; {
                    let imgNode = document.createElement(&quot;img&quot;);
                    imgNode.setAttribute('src', data.url)
                    $(this).summernote('insertNode', imgNode);
                  })
                }
              }
            });
        });
                   var sendFile = function(file, callback) {
                    var data;
                    data = new FormData();
                    data.append(&quot;file&quot;, file);
                    return $.ajax({
                      url: &quot;/addImgSummer&quot;,
                      data: data,
                      cache: false,
                      contentType: false,
                      processData: false,
                      type: 'POST',
                      success: function(data) {
                        return callback(data);
                      }
                    });
                  };
&lt;/style&gt;

0
0
3.7
10
Phoenix Logan 186120 points

                                    @app.route(&quot;/addImgSummer&quot;, methods=[&quot;POST&quot;])
def addImgSummer():
    #Grabbing file:
    img = request.files[&quot;file&quot;]    #&lt;------ THIS LINE RIGHT HERE! Is #literally all I needed lol.

    # Below is me replacing the img &quot;src&quot; with my S3 bucket link attached, with the said filename that was added. 
    imgURL = &quot;https://&quot;+ S3_BUCKET_NAME +&quot;.s3.amazonaws.com/images/&quot;+ img.filename

    return jsonify(url = imgURL)

3.7 (10 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source