[英]python flask URL error: 'The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.'
When I try to apply the url route I got this error.当我尝试应用 url 路由时,出现此错误。 Here is the code:这是代码:
from flask import Flask
from flask_restplus import Resource, Api
app = Flask(__name__)
api = Api(app)
@api.route('/GET/collections/<id>/<year>?q=<query>')
class DataRetrive(Resource):
def get(self,id, year, query):
return 'yes'
if __name__ == '__main__':
app.run(debug=True)
I think you don't need specify the query parameter "q"我认为您不需要指定查询参数“q”
try something like this:尝试这样的事情:
from flask import Flask, request
from flask_restplus import Resource, Api
app = Flask(__name__)
api = Api(app)
@api.route('/GET/collections/<id>/<year>')
class DataRetrive(Resource):
def get(self,id, year):
q = request.args.get('q')
return 'yes'
if __name__ == '__main__':
app.run(debug=True)
Pay attention to the country parameter that you have not defined ...注意你还没有定义的国家参数...
So your url looks like this:所以你的网址看起来像这样:
localhost:5000/GET/collections/1/2020?q=something本地主机:5000/GET/collections/1/2020?q=something
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.