def index(): return "Login In or Sign Up!" @app.route('/boards', methods=('GET', 'POST')) def display_boards(): boards = models.Board.select() return render_template('boards.html', boards=boards) @app.route('/b/<board_name>', methods=('GET', 'POST')) def show_board_content(board_name): lists = (models.List.select(models.List, models.Board).join( models.Board).where(models.Board.board_name == board_name).order_by( models.List.created_at.asc())) tasks = [] for l in lists: tasks.append( models.Task.select(models.List, models.Task).join( models.List).where(models.List.name == l.name)) return render_template('lists.html', lists=lists, tasks=tasks, board_name=board_name) if __name__ == '__main__': models.initialize() app.run(debug=DEBUG, host=HOST, port=PORT)
""" Ensure all responses have the CORS headers. This ensures any failures are also accessible by the client. """ resp.headers['Access-Control-Allow-Origin'] = request.headers.get( 'Origin', '*') resp.headers['Access-Control-Allow-Credentials'] = 'true' resp.headers['Access-Control-Allow-Methods'] = 'POST, OPTIONS, GET' resp.headers['Access-Control-Allow-Headers'] = request.headers.get( 'Access-Control-Request-Headers', 'Authorization') # set low for debugging if app.debug: resp.headers['Access-Control-Max-Age'] = '1' return resp if __name__ == '__main__': initialize(re_createTable) try: User.create_user( title='Mr', fname='Musa', lname='Salihu', username='******', email='*****@*****.**', password='******', address= 'Block 46A-3-4 Siri Ixora Jalan Pjs Seksen 29/11 Shah Alam Malaysia', state='Selangor', is_Admin=True) except: pass
@app.before_request def before_request(): """Connect to the database connection before each request. """ g.user = current_user # The method after is called after each request @app.after_request def after_request(response): """Close database connection after each request. """ # g.db.close() return response if __name__ == "__main__": initialize(re_createTable) try: User.create_user( title="MR", fname="Musa", lname="Salihu", username="******", email="*****@*****.**", password="******", address="Block 46A-3-4 Siri Ixora Jalan Pjs Seksen 29/11 Shah Alam Malaysia", state="Selangor", is_Admin=True, ) except: pass
@app.after_request def after_request(response): g.db.close() return response @app.route('/') def index(): return "Login In or Sign Up!" @app.route('/boards', methods=('GET', 'POST')) def display_boards(): boards = models.Board.select() return render_template('boards.html', boards=boards) @app.route('/b/<board_name>', methods=('GET', 'POST')) def show_board_content(board_name): lists = (models.List.select(models.List, models.Board) .join(models.Board) .where(models.Board.board_name == board_name) .order_by(models.List.created_at.asc())) tasks = [] for l in lists: tasks.append(models.Task.select(models.List, models.Task).join(models.List).where(models.List.name == l.name)) return render_template('lists.html', lists=lists, tasks=tasks, board_name=board_name) if __name__ == '__main__': models.initialize() app.run(debug=DEBUG, host=HOST, port=PORT)