报错404 单独调用yushu_book 有数据
来源:3-7 从API获取数据
qq_海的彼岸_1
2020-09-10
这个模块单独调用是有数据的
from httper import HTTP
class YuShuBook():
isbn_url = 'http://t.yushu.im/v2/book/isbn/{}'
keywork_url = ‘http://t.yushu.im/v2/book/search?q={}&count={}&start={}’
@classmethod
def search_by_isbn(cls, isbn):
url = cls.isbn_url.format(isbn)
result = HTTP.get(url)
return result
@classmethod
def search_by_keyword(cls, keyword, count=15, start=0):
url = cls.keywork_url.format(keyword, count, start)
result = HTTP.get(url)
return result
if name == “main”:
print(YuShuBook.search_by_isbn(9787121022982))
print(YuShuBook.search_by_keyword(“郭敬明”))
在postman 执行就是报错 404 老师看下面哪里写错了?
app.route(’/book/search//’)
def search(q, page):
’’‘
q: 普通关键字 isbn
page
:return:
’’'
isbn_or_key = is_isbn_or_key(q)
if isbn_or_key == “isbn”:
result = YuShuBook.search_by_isbn(q)
else:
result = YuShuBook.search_by_keyword(q)
return json.dumps(result)
2回答
-
postman 404?代码是可以的?那你看看你代码的url是什么呢?
012020-09-19 -
qq_海的彼岸_1
提问者
2020-09-11
#主入口
if __name__ == "__main__":
app.run(debug=app.config['DEBUG'], host="0.0.0.0", port=5000)# Postman url:
http://127.0.0.1:5000/book/search/9787501524044/1
# Postman 报错信息
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try
again.</p>
012020-09-11
相似问题