“FLASK GET SUMMERNOTE Texte” Réponses codées

FLASK GET SUMMERNOTE Texte

<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 SUMMERNOTE Texte

@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

Réponses similaires à “FLASK GET SUMMERNOTE Texte”

Questions similaires à “FLASK GET SUMMERNOTE Texte”

Plus de réponses similaires à “FLASK GET SUMMERNOTE Texte” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code