![](/img/trans.png)
[英]FLASK - The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again
[英]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.'
当我尝试应用 url 路由时,出现此错误。 这是代码:
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)
我认为您不需要指定查询参数“q”
尝试这样的事情:
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)
注意你还没有定义的国家参数...
所以你的网址看起来像这样:
本地主机:5000/GET/collections/1/2020?q=something
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.