[英]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.