'pythonanywhere is not updating mongoDB

@app.route('/signup', methods=['POST'])
def signup():
    info = request.args
    if info["password"] == info["password2"] and info["name"] and info["email"] and info["password"] and info["password2"]:
        password = os.getenv("password")
        link = 'mongodb+srv://yakov:' + password + '@cluster0.irzzw.mongodb.net/myAuctionDB?retryWrites=true&w=majority'
        client = MongoClient(link)
        db = client.get_database('myAuctionDB')
        users = db.users
        users.insert_one({
            'name': info["name"],
            'email': info["email"],
            'password': info["password"],
            'sales': [],
            'offers': [],
            'saved': []
        })
        return jsonify({"status": "ok", "message": " welcome to {} {} ".format(info["name"], info["email"])})
    else:
        return jsonify({"status": "error", "message": "you are missing some arguments"})

this is my code, it works when i run it locally from my computer. i saved it on a host called pythonanywhere, and the code works, but it does not insert the json to mongoDB, it gives me this error "500 Internal Server Error". this is the response when i run it locally: enter image description here

this is the response of the same code when i run it through pythonanywhere: enter image description here



Solution 1:[1]

Using a free acount in pythonanywhere, does not allow to connect to mongodb atlas, so when it runs on pythonanywhere, it does not connect to the database, and does not work

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yakov Bader