'How to send form data to MongoDB using Flask
I'm a student and trying to make a simple image uploading API using form data and MongoDB. But I'm having hard time solving errors.
I think it's the server side that keeps making the problems but I really can't find what exactly is wrong.
@app.route("/insta_feed1", methods=["POST"])
def feed_post():
file = request.form.get['file']
image = request.form.get['image']
content = request.form.get['content']
user_id = request.form.get['user_id']
doc = {'file': file, 'image': image, 'content': content, 'user_id': user_id}
db.insta_feed1.insert_one(doc)
return jsonify({'msg': 'image uploaded'})
I have files and contents appeded like this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|