What is the best way to sanitize inputs with Flask and when using MongoDB?

Viewed 13446

I'm writing my application backend with Python Flask. As part of the registration process, I have a form that sends the new user's information to my backend and then adds it to my MongoDB database.

I'm pretty new in this world and never wrote something that has to be secured..

My Python code looks like that:

from flask import Flask, request

app = Flask(__name__)


@app.route('/register', methods=['POST'])
def register():
    username = request.form['username']
    password = request.form['password']

Is there a Python library that sanitizes the request.form['username'] and request.form['password'] field for me? Something that make me safe from XSS and data leaks?

Thanks ahead!

1 Answers
Related