def add_link(): pjson = json.loads(request.data) source = Base.find_by_id(pjson.get('source_label'), pjson.get('source')) if source: if pjson.get('rel') in Base.rels: res = source.create_rels( pjson.get('target'), pjson.get('target_label'), pjson.get('rel')) if res: return jsonify({'result': "Ok"}), 200 else: return jsonify({'result': "relationship exists"}), 409 else: return jsonify({'result': "relationship not allowed"}), 201 return jsonify({'result': "Source not found"}), 404
def game_loop(): bird = Bird(200, 200) base = Base(730) pipes = [Pipe(600)] window = pygame.display.set_mode((WN_WIDTH, WN_HIGHT)) pygame.display.set_caption('Flappy Bird') clock = pygame.time.Clock() score = 0 run = True start = True # e = True while run: clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: run = False keys_pressed = pygame.key.get_pressed() if start: draw_window(window, bird, base, pipes, score) if keys_pressed[pygame.K_SPACE]: bird.jump() start = False else: remove_pipes = [] passed = False crashed = False if base.collide(bird): crashed = True crash(window, score) for pipe in pipes: if pipe.collide(bird): crashed = True crash(window, score) break if pipe.x + pipe.PIPE_TOP.get_width() < 0: remove_pipes.append(pipe) if not pipe.passed and pipe.x < bird.x: pipe.passed = True passed = True pipe.move() # in case of collision check if player wants to replay if crashed: keys_pressed = pygame.key.get_pressed() if keys_pressed[pygame.K_SPACE]: main() else: # if the bird passed the pipe increment score and add new pipe if passed: score += 1 pipes.append(Pipe(600)) # delete pipes that are out of the screen for remove in remove_pipes: pipes.remove(remove) # check if the bird hit the ground if bird.x + bird.img.get_height() >= 730: pass keys_pressed = pygame.key.get_pressed() # jump while playing if keys_pressed[pygame.K_SPACE]: bird.jump() bird.move() base.move() draw_window(window, bird, base, pipes, score)
def components(): return jsonify({'components': Base.find_all('Component')})
def get_children(app_id): return jsonify({'parent': app_id, 'children': Base.find_children(app_id)})
def get_applications(): return jsonify({'applications': Base.find_all('Application')})
def get_people(): return jsonify({'people': Base.find_all('Person')})