“Flask Get Summenote Text” Code-Antworten

Flask Get Summenote Text

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

Flask Get Summenote Text

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

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

    return jsonify(url = imgURL)
Gentle Goosander

Ähnliche Antworten wie “Flask Get Summenote Text”

Fragen ähnlich wie “Flask Get Summenote Text”

Weitere verwandte Antworten zu “Flask Get Summenote Text” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen