1

/date 处的 API 结果给出了 {"message": "Internal server error"} 错误。/hello 成功返回“hello world”。

最终目标是返回今年到目前为止经过的天数。

'''

from chalice import Chalice
from datetime import date

app = Chalice(app_name='days')
app.debug = True

@app.route('/hello')
def index():
    return {'hello': 'world'}

@app.route('/date')
def days():
    return date.today()

'''

4

1 回答 1

0

根据评论。

问题是date.today()没有返回 json

解决方案是将其转换为字符串,以便正确识别为 json 字符串:类似于str(date.today())

于 2020-07-25T05:54:27.180 回答