posting+video_part预

This commit is contained in:
2022-05-01 23:07:14 +08:00
parent 143367c29e
commit 7d9fb8d73d
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,19 @@
from flask import Blueprint, jsonify
from model.Posting import Posting
from util.flask import not_found_json_response
blueprint = Blueprint("api_posting", __name__, url_prefix="/api/posting")
@blueprint.get("/")
def get_all_posting():
_posting = Posting.query.all()
return jsonify([_i.to_json() for _i in _posting])
@blueprint.get("/<int:posting_id>")
def get_posting_detail(posting_id):
posting = Posting.query.get(posting_id)
if posting is None:
return not_found_json_response(id=posting_id)
return jsonify(posting.to_dict())