Questions tagged [flask-restful]

Flask-RESTful provides an extension to Flask for building REST APIs. Flask-RESTful was initially developed as an internal project at Twilio, built to power their public and internal APIs.

Project repo is maintain on Github currently.
The latest document is here
Its pypi info can be find here

1619 questions
7
votes
1 answer

marshalling dictionary with variable keys in flask restful /plus

I am building an API using flask-restful. I am also using flask-resfulplus for generating swagger documentation. I want to return a dictionary of items where the key is going to vary depending on the item. My model looks like this: item =…
nick_v1
  • 1,654
  • 1
  • 18
  • 29
7
votes
3 answers

Flask Restful accept a list in a post request

I am using Flask Restful for my server API and am posting to the server a dictionary where one of the values is a list of dictionary's. parser.add_argument('products_in_basket', type=list) def post(self, user_id): args = parser.parse_args() …
user4591756
7
votes
1 answer

Getting 500 INTERNAL SERVER ERROR when unittesting a (flask-restful) GET API Call

I have unittested all the methods from my flask-restful API module. Now I want to test get method by actually making the API call. I expect error 400 from this test. My resource class class Response(Resource): …
Hussain
  • 5,057
  • 6
  • 45
  • 71
7
votes
1 answer

How to specify that an argument is optional in flask-restful

I have code like this: def delete(self, rid): parser = reqparse.RequestParser() parser.add_argument('rating', default=2, type=int, help='blablabla') args = parser.parse_args() rating = args['rating'] ... return {'message':…
hbrls
  • 2,110
  • 5
  • 32
  • 53
7
votes
3 answers

TypeError on CORS for flask-restful

While trying the new CORS feature on flask-restful, I found out that the decorator can be only applied if the function returns a string. For example, modifying the Quickstart example: class HelloWorld(restful.Resource): …
user3022063
  • 73
  • 1
  • 3
6
votes
3 answers

Face Detection using Web(Html css) and Python

I am pretty new to web technologies. I am making a chatbot with face detection integrated although I know how to work with python and its libs with other works, i am facing issue while loading the pages Requirement: Face detection on web, for now,…
Tapan Kumar Patro
  • 767
  • 1
  • 7
  • 18
6
votes
1 answer

how to do unit test for functions inside of Resource class in flask-restful?

I am quite new to unit testing and relatively new to RESTful API development as well. I am wondering how to do unit test for functions inside Resource class in flask restful? I can do unit test for the endpoint's response but I don't know how to do…
addicted
  • 2,901
  • 3
  • 28
  • 49
6
votes
5 answers

TypeError: Object of type is not JSON serializable

I'm wrote rest on the Flask using flask-marshmallow models.py class Application(db.Model): __tablename__ = 'applications' id = db.Column(db.String(), primary_key=True) name = db.Column(db.String()) versions =…
unknown
  • 252
  • 3
  • 12
  • 37
6
votes
2 answers

POST method to upload file with json object in python flask app

I am stuck in a problem where I am trying to build single API which will upload file along with json object. I need this API to create webhook. Using multi part, I am able to upload file and in option filed I am able to send json object. In flask…
6
votes
2 answers

Why is my Flask error handler not being called?

I am trying to create a custom error handler in Flask 1.0.2 and Flask-RESTful 0.3.7, using the guidelines on the "Implementing API Exceptions" page. (Flask-RESTful has its own way of creating custom error messages, but since it doesn't seem to have…
David White
  • 1,763
  • 2
  • 16
  • 27
6
votes
2 answers

flask_jwt_extended is throwing an error decoding my JWT. How can I capture it?

I'm having issues trying to capture a malformed JWT error in my app. I'm using flask_jwt_extended and when I send a manually created JWT. I get this error message: Error on request: Traceback (most recent call last): File…
NotMe
  • 745
  • 2
  • 7
  • 26
6
votes
1 answer

How to load in arguments using marshmallow and flask_restful?

I have a flask_restful API set up but want users to pass numpy arrays when making a post call. I first tried using reqparse from flask_restful but it doesn't support data types of numpy.array. I am trying to use marshmallow (flask_marshmallow) but…
ladderfall
  • 145
  • 6
6
votes
1 answer

How to send multiple parameters to route using flask?

I started learning Flask framework recently and made a short program to understand request/response cycle in flask. My problem is that last method called calc doesn't work. I send request as: http://127.0.0.1/math/calculate/7/6 and I get…
Penguen
  • 16,836
  • 42
  • 130
  • 205
6
votes
1 answer

Pass filter and sort parameters in query string HTTP request and parse with Flask

I'm developing a REST api with Flask. One of my endpoints should support filtering and sorting. lets say i have these fields: category, color, severity. Lets say i want to get all the items that category is 'a'or 'b' and the color is black and sort…
sborpo
  • 928
  • 7
  • 15
6
votes
2 answers

Adding resources with jwt_required?

I've created an API using flask, where the authentication is all working fine using flask_jwt_extended. However if I add a resource that has a jwt_required decorator I get this error. File…
James MV
  • 8,569
  • 17
  • 65
  • 96