当前位置: 首页>>代码示例>>Python>>正文


Python Amenity.name方法代码示例

本文整理汇总了Python中app.models.amenity.Amenity.name方法的典型用法代码示例。如果您正苦于以下问题:Python Amenity.name方法的具体用法?Python Amenity.name怎么用?Python Amenity.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.models.amenity.Amenity的用法示例。


在下文中一共展示了Amenity.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_asdfstate

# 需要导入模块: from app.models.amenity import Amenity [as 别名]
# 或者: from app.models.amenity.Amenity import name [as 别名]
def create_asdfstate():
    content = request.get_json()
    if not all(param in content.keys() for param in ["name"]):
        #ERROR
        return "Failed: bad input"
    try:
        amenity = Amenity()
        amenity.name = content["name"]
        amenity.save()
    except Exception as e:
        return "Failed"
    return "Success"
开发者ID:Praylin,项目名称:airbnb_clone,代码行数:14,代码来源:amenity.py

示例2: create_amenity

# 需要导入模块: from app.models.amenity import Amenity [as 别名]
# 或者: from app.models.amenity.Amenity import name [as 别名]
def create_amenity():
    """
    Create an amenity
    Creates an amenity based on post parameters.
    ---
    tags:
      - amenity
    parameters:
      - name: name
        in: query
        type: string
        description: name of the amenity to create
    responses:
      200:
        description: Success message
        schema:
          id: success_message
          properties:
            status:
              type: number
              description: status code
              default: 200
            msg:
              type: string
              description: Status message
              default: 'Success'
      400:
          description: Error message
          schema:
            id: error_message
            properties:
              status:
                type: number
                description: status code
                default: 40000
              msg:
                type: string
                description: Status message
                default: 'Missing parameters'
    """
    content = request.get_json(force=True)
    if not content: return error_msg(400, 400, "Error")
    if not all(param in content.keys() for param in ["name"]):
        #ERROR
        return error_msg(400, 40000, "Missing parameters")
    try:
        amenity = Amenity()
        amenity.name = content["name"]
        amenity.save()
    except Exception as e:
        return error_msg(400, 400, "Error")
    return error_msg(200, 200, "Success")
开发者ID:johnSerrano,项目名称:airbnb_clone,代码行数:54,代码来源:amenities.py


注:本文中的app.models.amenity.Amenity.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。