def post(self): try: payload = request.get_json(silent=True) if not payload: return responsify( message='Invalid JSON content, or content-type header ' 'is not set to application/json'), 400 connector = current_app.connector jammer_repository = JammerRepository(connector) jammers_ = {'jammers': payload.get('jammers')} jammer_id = jammer_repository.insert(jammers_) jammers = jammer_repository.find_by(id=jammer_id) connector.commit() connector.close() return responsify(uuid=jammers['uuid']), 200 except Exception: response = tracer.build() logging.exception('create jammers failed') return response, 500
def post(self): try: payload = request.get_json(silent=True) if not payload: return responsify( message='Invalid JSON content, or content-type header ' 'is not set to application/json'), 400 connector = current_app.connector icecast_status_repository = IcecastStatusRepository(connector) source_ = {'source': json.dumps(payload.get('source'))} id_ = icecast_status_repository.insert(source_) icecast_status = icecast_status_repository.find_by(id=id_) connector.commit() connector.close() return responsify(uuid=icecast_status['uuid']), 200 except Exception: response = tracer.build() logging.exception('create icecast_status failed') return response, 500
def get(self): try: jammers = utils.load(os.path.join('/opt', 'jamulus', 'status')) print(jammers) return responsify(jammers=jammers), 200 except Exception: response = tracer.build() logging.exception('show property failed') return response, 500
def get(self): try: connector = current_app.connector name = request.args.get('name') if not name: return jsonify(message='property name is required'), 400 property_repository = PropertyRepository(connector) property_ = property_repository.find_by_name(name) print(property_) logging.debug(property_) if not property_: return jsonify(message='property not found'), 404 return responsify(property=property_), 200 except Exception: response = tracer.build() logging.exception('show property failed') return response, 500
def post(self): try: payload = request.get_json(silent=True) if not payload: return responsify( message='Invalid JSON content, or content-type header ' 'is not set to application/json'), 400 username = payload.get('username') password = payload.get('password') if not username: logging.debug('no username given') return responsify(message='invalid username or password'), 400 if not password: logging.debug('no password given') return responsify(message='invalid username or password'), 400 connector = current_app.connector user_repository = UserRepository(connector) user = user_repository.find_by_username(username) if not user: logging.debug('user not found') return responsify(message='invalid username or password'), 400 # hash the given password, so it can be checked against the hashed password # stored in the database password = hasher.sha256(password) if password != user.get('password'): logging.debug('invalid password') return responsify(message='invalid username or password'), 401 access_token = create_access_token(identity=username) return responsify(access_token=access_token), 200 except Exception: response = tracer.build() logging.exception('authentication failed') return response, 500