Exemple #1
0
 def post(self):
     args = parser.parse_args()
     user = Users(username=args.username, email=args.email)
     db.session.add(user)
     db.session.commit()
     db.session.remove()
     return handle_success(message='add success', code='10201')
Exemple #2
0
 def delete(self, user_id):
     user = Users.query.filter_by(id=user_id).first()
     if user is None:
         return handle_error(
             message="User {} doesn't exist".format(user_id), code='10404')
     db.session.delete(user)
     db.session.commit()
     db.session.remove()
     return handle_success(message='delete success', code='10204')
Exemple #3
0
 def put(self, user_id):
     args = parser.parse_args()
     user = Users.query.filter_by(id=user_id).first()
     user.username = args.username
     user.email = args.email
     data = user.to_json()
     db.session.commit()
     db.session.remove()
     return handle_success(message='update success',
                           code='10204',
                           data=data)
Exemple #4
0
def make_10_mock_data():
    from models.user import User

    dev_sqlite_file = os.path.join(os.path.dirname(__file__),
                                   'data-dev.sqlite')
    if os.path.exists(dev_sqlite_file):
        fake = Faker()
        for _ in range(10):
            o = User(fake.name(), fake.email())
            db.session.add(o)
        db.session.commit()
        return handle.handle_success()
    else:
        db.create_all()
        return handle.handle_error(data='setup env, please try again')
Exemple #5
0
def root_path():
    return handle_success()
Exemple #6
0
def endpoint():
    data = 'endpoint is %s' % '/xls/'
    return handle.handle_success(data=data)
Exemple #7
0
 def get(self):
     query = Users.query.all()
     list = [o.to_json() for o in query]
     return handle_success(message='query success', data=list)
Exemple #8
0
 def get(self, user_id):
     user = Users.query.filter_by(id=user_id).first()
     if user is None:
         return handle_error(
             message="User {} doesn't exist".format(user_id), code='10404')
     return handle_success(message='query success', data=user.to_json())
Exemple #9
0
def health_check():
    cmd = 'ls /opt'
    data = Command().get_status_output(cmd)
    return handle.handle_success(str(data))