1<form action="/updateTest" method="POST">
2 <h1 style="text-align:center">content</h1><textarea name=content id="summernote">{{value}</textarea>
3 <input class="input-btn" type="submit" value="Update">
1@app.route("/addImgSummer", methods=["POST"])
2def addImgSummer():
3 #Grabbing file:
4 img = request.files["file"] #<------ THIS LINE RIGHT HERE! Is #literally all I needed lol.
5
6 # Below is me replacing the img "src" with my S3 bucket link attached, with the said filename that was added.
7 imgURL = "https://"+ S3_BUCKET_NAME +".s3.amazonaws.com/images/"+ img.filename
8
9 return jsonify(url = imgURL)
1<style>
2$(document).ready(function() {
3 $('#summernote').summernote({
4 height: 300,
5 focus: true,
6 callbacks: {
7 onImageUpload(files) {
8 sendFile(files[0], data => {
9 let imgNode = document.createElement("img");
10 imgNode.setAttribute('src', data.url)
11 $(this).summernote('insertNode', imgNode);
12 })
13 }
14 }
15 });
16 });
17 var sendFile = function(file, callback) {
18 var data;
19 data = new FormData();
20 data.append("file", file);
21 return $.ajax({
22 url: "/addImgSummer",
23 data: data,
24 cache: false,
25 contentType: false,
26 processData: false,
27 type: 'POST',
28 success: function(data) {
29 return callback(data);
30 }
31 });
32 };
33</style>