I am using Flask and MongoDB. I am trying to convert the content of request.form into something suitable for saving via PyMongo. It seems like something that should come up
The Flask ImmutableMultiDict data structure has a built in to_dict method.
This knowledge in addition to the Flask request object form property being an ImmutableMultiDict allows for simple handling of a form POST request to MongoDB.
See below for a naive example:
from flask import request
@app.route('/api/v1/account', methods=['POST'])
def create_account():
"""Create user account"""
account_dict = request.form.to_dict()
db.account.insert_one(account_dict)