forked from Ada-C22/back-end-inspiration-board
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from hintow/wei
Wei
- Loading branch information
Showing
5 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from flask import Blueprint, abort, make_response, request, Response | ||
from app.models.board import Board | ||
from ..db import db | ||
import requests | ||
import json | ||
import os | ||
|
||
bp=Blueprint("boards_bp", __name__, url_prefix="/boards") | ||
|
||
@bp.post("") | ||
def create_board(): | ||
request_body = request.get_json() | ||
try: | ||
new_board = Board.from_dict(request_body) | ||
except KeyError as e: | ||
missing_key = e.args[0] | ||
response = {"details": f"Invalid request body: Missing key '{missing_key}'"} | ||
abort(make_response(response, 400)) | ||
|
||
db.session.add(new_board) | ||
db.session.commit() | ||
|
||
response = {"board": new_board.to_dict()} | ||
return response, 201 |