def get_user(username: str): Users = db['users'] return jsonify(Users.find_one({"_id": username}))
def updateCourseInfoOfUser(course, filter, role): Users = db['users'] if role == "student": Users.update_one({**filter}, {"$push": {"courseEnrolled": course}}) elif role == "teacher": Users.update_one({**filter}, {"$push": {"courseAssigned": course}})
def check_user(username: str, password: str): Users = db['users'] return Users.find_one({"_id": username, "password": password})
from flask import Flask from pymongo import MongoClient from flask_cors import CORS app = Flask(__name__) CORS(app=app, support_credentials=True) client = MongoClient(host='localhost',port=27017) db = client.AttendenceSystem ## INITIATING COLLECTIONS from app.Collections.Courses import Courses from app.Collections.Departments import Departments from app.Collections.Users import Users Courses.create() Departments.create() Users.create() from app.Controllers import courseController from app.Controllers import departmentController from app.Controllers import userController from app.Controllers import studentController from app.Controllers import teacherController