Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates a simple Flask-RESTful API with a Todo resource for listing and creating items.
from flask import Flask, request
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
todos = []
class TodoResource(Resource):
def get(self):
return todos
def post(self):
data = request.get_json()
todos.append(data)
return data, 201
api.add_resource(TodoResource, '/todos')
if __name__ == '__main__':
app.run(debug=True)Flask-RESTful is an extension for Flask that adds support for quickly building REST APIs. It provides resource-based routing, request parsing, and easy integration with Flask’s ecosystem.
Origin & Creator
Created by Twilio engineers in 2013 as an open-source extension to Flask.
Industrial Note
Flask-RESTful is often used in startups, prototypes, and smaller projects where quick API development and flexibility matter more than extreme performance.