如果您手动输入网址,请检查拼写,然后重试。找不到网址

时间:2019-07-17 10:03:04

标签: python api flask

@app.route('/api/<int:q_isbn>')
def isbn(q_isbn):
    res = db.execute("SELECT * FROM books WHERE isbn LIKE :isbn LIMIT 1", {"isbn": q_isbn}).fetchone()
    if res is None:
        return jsonify(
            {
                "error_code": 404,
                "error_message": "Not Found"
            }
        )
    result = {
        "title": res.title,
        "author": res.authors,
        "year": res.year,
        "isbn": res.isbn,
    }
    return jsonify(result)

0 个答案:

没有答案