def __init__(self, DirectAPI: DirectAPIRegister, mongo: MongoClient): self.subjects = mongo.db.subjects DirectAPI.register('/subjects', lambda: 'Here are some APIs about subjects') DirectAPI.register('/subjects/all', self.subjects_all) DirectAPI.register('/subjects/add', self.subjects_add) DirectAPI.register('/subjects/del', self.subjects_del)
from DirectAPIFramework import DirectAPIApp, DirectAPIRegister from MongoOrm import MongoConnection from APIs import RootAPI, SubjectsAPI, ClassesAPI, InspectorsAPI, RecordsAPI, AdminsAPI if __name__ == '__main__': directApiRegister = DirectAPIRegister() mongo = MongoConnection('didsys') RootAPI(directApiRegister) SubjectsAPI(directApiRegister, mongo) ClassesAPI(directApiRegister, mongo) InspectorsAPI(directApiRegister, mongo) RecordsAPI(directApiRegister, mongo) AdminsAPI(directApiRegister, mongo) app = DirectAPIApp(8080, directApiRegister) app.run()
def __init__(self, DirectAPI: DirectAPIRegister, mongo: MongoClient): self.admins = mongo.db.admins DirectAPI.register('/admins', lambda: 'Here are APIs about admins')
def __init__(self, DirectAPI: DirectAPIRegister, mongo: MongoClient): self.records = mongo.db.records DirectAPI.register('/records', lambda: 'Here are APIs about records')
def __init__(self, DirectAPI: DirectAPIRegister): DirectAPI.register('/author', lambda: "HankelBao") DirectAPI.register('/', lambda: "DIDSYS API System")
def __init__(self, DirectAPI: DirectAPIRegister, mongo: MongoClient): self.inspectors = mongo.db.inspectors DirectAPI.register('/inspectors', lambda: 'Here are APIs about inspectors')
def __init__(self, DirectAPI: DirectAPIRegister, mongo: MongoClient): self.classes = mongo.db.classes DirectAPI.register('/classes', lambda: 'Here are APIs about classes')