MCPcopy Index your code
hub / github.com/FloatingOctothorpe/python-kanban / create_app

Function create_app

main.py:11–97  ·  view source on GitHub ↗

Create a new instance of the flask app

()

Source from the content-addressed store, hash-verified

9import cards
10
11def create_app():
12 """Create a new instance of the flask app"""
13 app = Flask(__name__)
14 app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///kanban.db'
15 app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
16 app.config['kanban.columns'] = ['To Do', 'Doing', 'Done']
17 db.init_app(app)
18 app.app_context().push()
19 db.create_all()
20
21 @app.route('/')
22 def index():
23 """Serve the main index page"""
24 return send_from_directory('static', 'index.html')
25
26 @app.route('/static/<path:path>')
27 def static_file(path):
28 """Serve files from the static directory"""
29 return send_from_directory('static', path)
30
31 @app.route('/cards')
32 def get_cards():
33 """Get an order list of cards"""
34 return jsonify(cards.all_cards())
35
36 @app.route('/columns')
37 def get_columns():
38 """Get all valid columns"""
39 return jsonify(app.config.get('kanban.columns'))
40
41 @app.route('/card', methods=['POST'])
42 def create_card():
43 """Create a new card"""
44
45 # TODO: validation
46 cards.create_card(
47 text=request.form.get('text'),
48 column=request.form.get('column', app.config.get('kanban.columns')[0]),
49 color=request.form.get('color', None),
50 )
51
52 # TODO: handle errors
53 return 'Success'
54
55 @app.route('/card/reorder', methods=["POST"])
56 def order_cards():
57 """Reorder cards by moving a single card
58
59 The JSON payload should have a 'card' and 'before' attributes where card is
60 the card ID to move and before is the card id it should be moved in front
61 of. For example:
62
63 {
64 "card": 3,
65 "before": 5,
66 }
67
68 "before" may also be "all" or null to move the card to the beginning or end

Callers 1

main.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected