flask如何写一个接口

 1 # -*- coding: utf-8 -*-
 2 
 3 # 导入一个蓝图
 4 from flask import Blueprint
 5 from graphics.utils import http_content_util
 6 from graphics.db_utils import car as db_util
 7 
 8 car_bp = Blueprint('car', __name__)
 9 
10 @car_bp.route('/new', methods=['POST', 'GET'])
11 def new_car():
12     car_id, model, plate_number = http_content_util.get_param_get_or_post("car_id", "model", "plate_number")
13     try:
14         db_util.insert_car(car_id, model, plate_number)
15         return http_content_util.response_ok()
16     except Exception as e:
17         return http_content_util.response_error(str(e))

 

posted @ 2021-05-21 16:07  年轻人——001  阅读(134)  评论(0编辑  收藏  举报