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))
全世界的程序员们联合起来吧!