本文整理汇总了Python中app.models.state.State.name方法的典型用法代码示例。如果您正苦于以下问题:Python State.name方法的具体用法?Python State.name怎么用?Python State.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.models.state.State
的用法示例。
在下文中一共展示了State.name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_state
# 需要导入模块: from app.models.state import State [as 别名]
# 或者: from app.models.state.State import name [as 别名]
def create_state():
"""
Create a state
Creates a state based on post parameters.
---
tags:
- state
parameters:
- name: name
in: query
type: string
description: name of the state 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 all(param in content.keys() for param in ["name"]):
#ERROR
return error_msg(400, 40000, "Missing parameters")
try:
state = State()
state.name = content["name"]
state.save()
except Exception as e:
return error_msg(400, 400, "Error")
return error_msg(200, 200, "Success")