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
21
votes
2 answers

Difference between namespaces and blueprints in flask-restful and flask

I am unable to understand the what purpose does blueprints and namespaces serve in web app. I read the documentation but cannot figure it out exactly. It would be really helpful for me if you give a simple explanation with example for each…
handsomer223
  • 885
  • 4
  • 12
  • 16
21
votes
3 answers

Python - How to run multiple flask apps from same client machine

I have one flask application script as given below : from flask import Flask app = Flask(__name__) @app.route("/") def main(job_id): return "Welcome!. This is Flask Test Part 1" if __name__ == "__main__": job_id = 1234 …
JKC
  • 2,498
  • 6
  • 30
  • 56
21
votes
1 answer

flask-RESTful vs flask-RESTless, which should be used, and when

What are the key differences of these two libraries.In terms of usability, and features If you already have a huge number of model classes, using flask-restLESS makes perfect sense, right?. What are the features it would lack, if it would done with…
ISONecroMAn
  • 1,460
  • 2
  • 16
  • 23
20
votes
1 answer

Calling REST API from the same server

I have a web application which is backed by REST API located on the same server. Let's say I have a Task resource accessible on /api/task/ and a web page /create-task which is basically just a form to create a task. There are several ways…
Marigold
  • 1,619
  • 1
  • 15
  • 17
19
votes
1 answer

Flask: A RESTful API and SocketIO Server

Background I am trying to create a simple REST API using the Flask-RESTful extension. This API will be working primarily to manage the CRUD and authentication of users for a simple service. I am also trying to create a few web sockets using the…
nmagerko
  • 6,586
  • 12
  • 46
  • 71
19
votes
3 answers

Flask-RESTful - don't return object property instead of returning null

Let's say I've got a clients table with id, name and email fields. An email field is optional. The code looks like this: client_fields = { 'id' : fields.String, 'name' : fields.String, 'email' : fields.String } And for displaying: class…
zorza
  • 2,814
  • 3
  • 27
  • 41
19
votes
1 answer

How to setup different subdomains in Flask (using blueprints)?

I have a Flask application running at https://app.mydomain.com. The blueprints look like this: app.register_blueprint(main) app.register_blueprint(account, url_prefix='/account') app.register_blueprint(users,…
okoboko
  • 4,332
  • 8
  • 40
  • 67
19
votes
2 answers

What is the datetime format for flask-restful parser?

Let's say that I have following parser inside my get method: from flask.ext.restful import reqparse parser = reqparse.RequestParser() parser.add_argument('when', type=datetime, help='Input wasn\'t valid!') And then I want to test the said get…
TukeV
  • 641
  • 2
  • 6
  • 13
19
votes
4 answers

Flask Restful add resource parameters

I am looking to pass an object instance as a parameter into a Flask-RESTfull Resource. Here is my setup: # in main.py from flask import Flask from flask.ext.restful import Api from bar import Bar from foo import views app = Flask(__name__) api =…
Gunther
  • 2,474
  • 4
  • 31
  • 45
19
votes
3 answers

How do I use flask.url_for() with flask-restful?

I have setup Flask restful like this: api = Api(app, decorators=[csrf_protect.exempt]) api.add_resource(FTRecordsAPI, '/api/v1.0/ftrecords/', endpoint="api.ftrecord") I would like to…
Houman
  • 64,245
  • 87
  • 278
  • 460
19
votes
4 answers

Extremely long wait time when loading REST resource from angularjs

I'm building a front-end in angular that is accessing a flask/python RESTful API. I'm using AngularJS v1.2.16. For some reason, it takes an insane amount of time before the REST resource is loaded, with most of the time just waiting. It's my…
18
votes
3 answers

Calling flask restful API resource methods

I'm creating an API with Flask that is being used for a mobile platform, but I also want the application itself to digest the API in order to render web content. I'm wondering what the best way is to access API resource methods inside of Flask? For…
user3026153
  • 183
  • 1
  • 1
  • 4
17
votes
2 answers

Accepting multiple parameters in flask-restful add_resource()

I want to handle a GET request in my Flask REST API. The request will include multiple parameters, and you can expect this to be a typical GET request: https://localhost:5000/item/analysis=true&class=A&class=B Thus, a GET request consists of: a…
Omkar Neogi
  • 675
  • 2
  • 9
  • 30
17
votes
1 answer

flask-sqlalchemy: AttributeError: type object has no attribute 'query', works in ipython

I'm creating a new flask app using flask-sqlalchemy and flask-restful with Python 3.4. I've defined my User model as such: from mytvpy import db from sqlalchemy.ext.declarative import declared_attr class BaseModel(db.Model): __abstract__ =…
postelrich
  • 3,274
  • 5
  • 38
  • 65
17
votes
2 answers

Flask-restful: marshal complex object to json

I have a question regarding flask restful extension. I'm just started to use it and faced one problem. I have flask-sqlalchemy entities that are connected many-to-one relation and I want that restful endpoint return parent entity with all its…
Zygimantas Gatelis
  • 1,923
  • 2
  • 18
  • 27