You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I would like to have a route with a param in it but not having to have to specify it in the method level, like:
Class ComponentList(Resource):
def get(self): # note that there is no some_random_string param here
...
api.add_resource(ComponentList, '/api/<some_random_string>/components')
For the moment I couldn't find any keyword in the code, * doesn't work either. Is it possible?
The text was updated successfully, but these errors were encountered:
Hi @bastianb , fortunately there isn't an option to do so.
I would suggest to create a middleware that catches this endpoint and then returns your resource response:
from flask_restful import Api, Resource
from flask import Flask, request
app = Flask(__name__)
api = Api(app)
class ComponentList(Resource):
def get(self): # note that there is no some_random_string param here
...
return "my_response"
@app.route('/api/<string:ignored>/components')
def middleware(ignored):
method = request.method.lower()
if hasattr(ComponentList, method):
return getattr(ComponentList(), method)()
if __name__ == '__main__':
app.run(debug=True)
Notice that if you need a scaleable solution you can use a class decorator
Hi,
I would like to have a route with a param in it but not having to have to specify it in the method level, like:
For the moment I couldn't find any keyword in the code,
*
doesn't work either. Is it possible?The text was updated successfully, but these errors were encountered: