Browsable web APIs for Flask.

Overview

Flask API

Browsable web APIs for Flask.

Unix Build Status Coverage Status Scrutinizer Code Quality PyPI Version

Status: This project is in maintenance mode. The original author (Tom Christie) has shifted his focus to API Star. Passing PRs will still be considered for releases by the maintainer (Jace Browning).

Overview

Flask API is a drop-in replacement for Flask that provides an implementation of browsable APIs similar to what Django REST framework offers. It gives you properly content-negotiated responses and smart request parsing:

Screenshot

Installation

Requirements:

  • Python 3.6+
  • Flask 1.1.+

Install using pip:

$ pip install Flask-API

Import and initialize your application:

from flask_api import FlaskAPI

app = FlaskAPI(__name__)

Responses

Return any valid response object as normal, or return a list or dict.

@app.route('/example/')
def example():
    return {'hello': 'world'}

A renderer for the response data will be selected using content negotiation based on the client 'Accept' header. If you're making the API request from a regular client, this will default to a JSON response. If you're viewing the API in a browser, it'll default to the browsable API HTML.

Requests

Access the parsed request data using request.data. This will handle JSON or form data by default.

@app.route('/example/')
def example():
    return {'request data': request.data}

Example

The following example demonstrates a simple API for creating, listing, updating and deleting notes.

from flask import request, url_for
from flask_api import FlaskAPI, status, exceptions

app = FlaskAPI(__name__)


notes = {
    0: 'do the shopping',
    1: 'build the codez',
    2: 'paint the door',
}

def note_repr(key):
    return {
        'url': request.host_url.rstrip('/') + url_for('notes_detail', key=key),
        'text': notes[key]
    }


@app.route("/", methods=['GET', 'POST'])
def notes_list():
    """
    List or create notes.
    """
    if request.method == 'POST':
        note = str(request.data.get('text', ''))
        idx = max(notes.keys()) + 1
        notes[idx] = note
        return note_repr(idx), status.HTTP_201_CREATED

    # request.method == 'GET'
    return [note_repr(idx) for idx in sorted(notes.keys())]


@app.route("/<int:key>/", methods=['GET', 'PUT', 'DELETE'])
def notes_detail(key):
    """
    Retrieve, update or delete note instances.
    """
    if request.method == 'PUT':
        note = str(request.data.get('text', ''))
        notes[key] = note
        return note_repr(key)

    elif request.method == 'DELETE':
        notes.pop(key, None)
        return '', status.HTTP_204_NO_CONTENT

    # request.method == 'GET'
    if key not in notes:
        raise exceptions.NotFound()
    return note_repr(key)


if __name__ == "__main__":
    app.run(debug=True)

Now run the webapp:

$ python ./example.py
 * Running on http://127.0.0.1:5000/
 * Restarting with reloader

You can now open a new tab and interact with the API from the command line:

$ curl -X GET http://127.0.0.1:5000/
[{"url": "http://127.0.0.1:5000/0/", "text": "do the shopping"},
 {"url": "http://127.0.0.1:5000/1/", "text": "build the codez"},
 {"url": "http://127.0.0.1:5000/2/", "text": "paint the door"}]

$ curl -X GET http://127.0.0.1:5000/1/
{"url": "http://127.0.0.1:5000/1/", "text": "build the codez"}

$ curl -X PUT http://127.0.0.1:5000/1/ -d text="flask api is teh awesomez"
{"url": "http://127.0.0.1:5000/1/", "text": "flask api is teh awesomez"}

You can also work on the API directly in your browser, by opening http://127.0.0.1:5000/. You can then navigate between notes, and make GET, PUT, POST and DELETE API requests.

Issues
  • Towards 1.0

    Towards 1.0

    I've been doing some preliminary work on a new Flask API framework. Given that I've never maintained Flask-API, and it's only ever been a very weak port of a few bits of REST framework, I'm strongly considering using this project for the latest work, and releasing it as a 1.0 version.

    I'm really pleased with the incoming work, which is super simple, but features automatic client libraries & command line tool, plus schema generation in a nice & agnostic way (so, eg provide Swagger, API Blueprint, or any other schema type documentation out of the box)

    I figure it's worth raising the issue here to see how folks would feel about an incompatible 1.0 release, if it was something that was actually going to push things forwards and be a release that I was actually using and significantly invested in for a change.

    Any thoughts?

    question 
    opened by tomchristie 14
  • New maintainer?

    New maintainer?

    @tomchristie has mentioned in #31 and #32 that he is not currently maintaining this project. I'm interested in helping support a 0.6.x release with bug fixes. Can we talk about which of these options is best to move forward on this repo:

    1. contributors create pull requests and @tomchristie merges
    2. add additional collaborators with push permission
    3. transfer ownership of this repo to someone else
    4. create a GitHub organization for this repo and add collaborators to that
    opened by jacebrowning 11
  • Release v0.6.3

    Release v0.6.3

    Also cleaned up some spelling/formatting issues for release.

    opened by jacebrowning 10
  • AttributeError: 'tuple' object has no attribute 'items'

    AttributeError: 'tuple' object has no attribute 'items'

    Related to #58, I am now hitting a spot where blueprint_handlers and app_handlers are both empty tuples with Flask 0.11 and 0.11.1, so the fix in #59 actually causes a new issue:

    Traceback (most recent call last):
      File ".../env/lib/python3.5/site-packages/flask/app.py", line 2000, in __call__
        return self.wsgi_app(environ, start_response)
      File ".../env/lib/python3.5/site-packages/flask/app.py", line 1991, in wsgi_app
        response = self.make_response(self.handle_exception(e))
      File ".../env/lib/python3.5/site-packages/flask/app.py", line 1567, in handle_exception
        reraise(exc_type, exc_value, tb)
      File ".../env/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
        raise value
      File ".../env/lib/python3.5/site-packages/flask/app.py", line 1988, in wsgi_app
        response = self.full_dispatch_request()
      File ".../env/lib/python3.5/site-packages/flask/app.py", line 1641, in full_dispatch_request
        rv = self.handle_user_exception(e)
      File ".../env/lib/python3.5/site-packages/flask_api/app.py", line 97, in handle_user_exception
        for typecheck, handler in chain(blueprint_handlers.items(), app_handlers.items()):
    AttributeError: 'tuple' object has no attribute 'items'
    
    help wanted 
    opened by jacebrowning 9
  • Using with a Blueprint

    Using with a Blueprint

    Does Flask-API supports blueprint? The example is only using the Flask initialization.

    opened by rabc 9
  • No content responses should accept not only an empty string

    No content responses should accept not only an empty string

    Is confusing, specially when trying to keep consistence beetwen returned data types, that to be able to send a 204 HTTP status code is needed to pass only an empty string not being valid and empty dictionary or None value for example.

    Could be more flexible to support other "empty/no content" values.

    help wanted 
    opened by jesugmz 7
  • Support for non-English string

    Support for non-English string

    I rewrite the notes in example.py

    notes = {
        0: '购物',
        1: 'build the codez',
        2: 'paint the door',
    }
    

    I get an exception: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 16: ordinal not in range

    opened by jacktan1991 7
  • Allow custom template when inheriting BrowsableAPIRenderer

    Allow custom template when inheriting BrowsableAPIRenderer

    It would be useful to be able to inherit BrowsableAPIRenderer and set a different jinja template.

    opened by jaidhyani 7
  • v0.7.0 release breaks expected behavior

    v0.7.0 release breaks expected behavior

    One of the chief reasons we use FlaskAPI at Qualcomm is because of how easy it makes returning JSON content from a simple function. However, it seems something between v0.6.9 and v0.7.0 broke this behavior; if you try to return data that isn't a dict or list from a Flask handler, you get a text/html response back, whereas you used to get an application/json response back.

    In v0.6.9:

    [[email protected]]$ curl --include --insecure https://10.52.252.96:3519/api/v1/mapping/test_mapping/key1
    HTTP/1.0 200 OK
    Content-Type: application/json
    Content-Length: 8
    Access-Control-Allow-Origin: *
    Server: Werkzeug/0.12.1 Python/3.5.3
    Date: Tue, 11 Apr 2017 03:40:13 GMT
    Connection: keep-alive
    
    "value1"
    

    In v0.7.0:

    [[email protected]]$ curl --include --insecure https://10.52.252.96:3519/api/v1/mapping/test_mapping/key1
    HTTP/1.0 200 OK
    Content-Type: text/html; charset=utf-8
    Content-Length: 6
    Access-Control-Allow-Origin: *
    Server: Werkzeug/0.12.1 Python/3.5.3
    Date: Tue, 11 Apr 2017 03:45:21 GMT
    Connection: keep-alive
    
    value1
    

    It's OK if the new behavior is intentional -- if so, just please provide a way to get the old behavior back, because we are depending on it.

    opened by skaven81 6
  • Project abandoned?

    Project abandoned?

    It seems that latest updated are getting and older. Same for other branches. Is the project fully abandoned with no v1.0 as planed?

    question 
    opened by vinyll 6
  • zip_safe flag not set; analyzing archive contents...ValueError: bad marshal data (unknown type code)

    zip_safe flag not set; analyzing archive contents...ValueError: bad marshal data (unknown type code)

    When installing Flask-API as a requirement for another application via python setup.py install I get:

    zip_safe flag not set; analyzing archive contents...
    flask_api.tests.__init__: module references __file__
    Traceback (most recent call last):
    

    ....

    ValueError: bad marshal data (unknown type code)
    
    opened by james-fanduel 6
  • Document how to customize the API theme

    Document how to customize the API theme

    I want use a different Template To Show My API Interface. How to set app.config? Can you show all of this array named app.config?

    help wanted documentation 
    opened by bestony 6
  • Request.parser_classes and Request.renderer_classes are hardcoded to be default

    Request.parser_classes and Request.renderer_classes are hardcoded to be default

    This looks like a very strange hard-code of the request's configuration:

        def preprocess_request(self):
            request.parser_classes = self.api_settings.DEFAULT_PARSERS
            request.renderer_classes = self.api_settings.DEFAULT_RENDERERS
            return super(FlaskAPI, self).preprocess_request()
    

    so it makes it impossible to extend the Request class and set it's classes attributes to a different from default values

    opened by bubenkoff 6
  • pypi package for 0.6.6 contains .pyc files.

    pypi package for 0.6.6 contains .pyc files.

    I am getting ValueError: bad marshal data (unknown type code) during install of an application with a requirement on 0.6.6.

    This looks like it could be due to the pypi package containing .pyc files.

    opened by james-fanduel 5
  • JSONRendered to use app's json_encoder

    JSONRendered to use app's json_encoder

    It would be good if one could change the default json_encoder class used for serialization. The one which is currently used is flask.json.JSONEncoder. Trying to change it like so

    app = FlaskAPI('the_app')
    app.json_encoder = CustomJSONEncoder
    

    does not have any effect.

    https://github.com/tomchristie/flask-api/blob/1.0/flask_api/renderers.py#L15

    Wouldn't something like

            return json.dumps(data, cls=current_app.json_encoder, ensure_ascii=False)
    

    instead of

            return json.dumps(data, cls=JSONEncoder, ensure_ascii=False)
    

    solve the problem?

    help wanted 
    opened by lalstef 5
  • fix for #58

    fix for #58

    I came across the issue recently for #58 as well, and saw the change was relatively simple.

    I added some tests in there as well to check the custom error handler was working okay, looks good on my end.

    opened by dutronlabs 5
  • Angle bracket escaping issue

    Angle bracket escaping issue

    Fixes #30.

    opened by tommorris 4
  • Detect when HTMLRenderer is appropriate

    Detect when HTMLRenderer is appropriate

    After a glance on the web I expected Flask API to be a drop-in solution to add an API functionality to my app. However, it is necessary to add the @set_renderers([HTMLRenderer]) before every view. Isn't it possible to make it implicit for functions returning an already rendered template?

    opened by lrem 4
  • Support for Flask MethodView

    Support for Flask MethodView

    Flask-API doesn't work with Flask's MethodView.

    opened by stephenmuss 4
  • ModuleNotFoundError: No module named flask_api

    ModuleNotFoundError: No module named flask_api

    Hi! Wonder if you can shed some light. Installed flask-api on a Raspberry Pi 3 using: sudo pip install Flask sudo pip install Flask-API No errors. Tested a small python program.

    from flask import request from flask_api import FlaskAPI .... Second line bombs with ModuleNotFoundError: No module name 'flask_api' Sure I'm missing something obvious. Trying to follow this sample: https://docs.dataplicity.com/docs/control-gpios-using-rest-api

    Very much appreciate your comments. Thanks so much!

    opened by sterenas 4
  • Add badges to homepage

    Add badges to homepage

    Kinda did the same thing done in http://www.django-rest-framework.org/. Closes #3

    opened by jpadilla 4
  • It's not compatiable with Flask-RESTful

    It's not compatiable with Flask-RESTful

    Hi. When I want to implement Flask-RESTful instead of native FLASK.

    So this code works

    from flask_api import FlaskAPI
    from flask_restful import Resource, Api
    
    app = FlaskAPI(__name__)
    
    # class HelloWorld(Resource):
    #     def get(self):
    #         return {'hello': 'world'}
    
    # api = Api(app)
    # api.add_resource(HelloWorld, '/')
    
    
    @app.route("/", methods=['GET', 'POST'])
    def welcome():
        return {"welcome":"world"}
    
    
    if __name__ == "__main__":
        app.run(debug=True, host='0.0.0.0', port=5000)
    

    But this code works, but not rendering HTML as expected

    
    from flask_api import FlaskAPI
    from flask_restful import Resource, Api
    
    app = FlaskAPI(__name__)
    
    class HelloWorld(Resource):
        def get(self):
            return {'hello': 'world'}
    
    api = Api(app)
    api.add_resource(HelloWorld, '/')
    
    
    #@app.route("/", methods=['GET', 'POST'])
    #def welcome():
    #    return {"welcome":"world"}
    
    
    if __name__ == "__main__":
        app.run(debug=True, host='0.0.0.0', port=5000)
    
    opened by Arlington1985 4
  • Allow formatting the docstring with markdown

    Allow formatting the docstring with markdown

    As in:

    def my_api_resource():
        """":markdown
        # this is my resource documentation
       parameters:
       - bla bla bla
       - foo bar
      """
      return [{...}]
    

    Create a template tag or filter to detect the presence of ":markdown" in the start of the doc to format in template using flask-mistune

    opened by rochacbruno 3
  • Detect the character encoding of the docstring for non-ascii characters.

    Detect the character encoding of the docstring for non-ascii characters.

    Formerly, if using Python 2.x and docstrings contain non-ascii characters, rendering has failed due to UnicodeDecodeError. I solved it to decode the docstring in that case, with the encoding of the module that contains the docstring.

    More details are included in the diff.

    opened by Kroisse 3
  • Incompatibility with flask .11 error handling: TypeError: 'type' object is not iterable

    Incompatibility with flask .11 error handling: TypeError: 'type' object is not iterable

    Flask 0.11 Changed the order in which errorhandlers are executed and they added the type of the error handler in there making any app that registers flask-api to throw an error before being able to execute the proper error handler (app.py line 91)

    What seems to work for me is to add the following in app.py:91

    for typecheck, handler in chain(blueprint_handlers.items(), app_handlers.items()): 
    

    since blueprint_handlers and app_handlers are now both dict objects

    opened by vitriol 3
  • Customize automatic API return types

    Customize automatic API return types

    Closes #77

    opened by jacebrowning 3
  • add 422 http status code constant to status

    add 422 http status code constant to status

    Hello there,

    Just want to add one small constant to status module.

    See http://stackoverflow.com/questions/16133923/400-vs-422-response-to-post-of-data https://tools.ietf.org/html/rfc4918#section-11.2

    opened by Axik 3
  • Content negotiation improvements

    Content negotiation improvements

    These changes fix a couple of content negotiation issues.

    The original code expected media type parameters to be separated with commas, when they should actually be separated with semicolons.

    I've also added support for the quality (q) parameter to allow the client to better influence the rendered that is selected.

    opened by james-emerton 3
  • AttributeError: 'NoneType' object has no attribute 'replace'

    AttributeError: 'NoneType' object has no attribute 'replace'

    The example (http://www.flaskapi.org/#example) shows that an empty string can be returned for DELETE on a resource:

    @app.route("/<int:key>/", methods=['GET', 'PUT', 'DELETE'])
    def notes_detail(key):
        ...
        elif request.method == 'DELETE':
            notes.pop(key, None)
            return '', status.HTTP_204_NO_CONTENT
    

    But with Flask 0.11 and Flask-API 0.6.6 this consistency causes this exception:

    Traceback (most recent call last):
      File ".../Flask-0.11-py3.5.egg/flask/app.py", line 2000, in __call__
        return self.wsgi_app(environ, start_response)
      File ".../Flask-0.11-py3.5.egg/flask/app.py", line 1991, in wsgi_app
        response = self.make_response(self.handle_exception(e))
      File ".../Flask-0.11-py3.5.egg/flask/app.py", line 1567, in handle_exception
        reraise(exc_type, exc_value, tb)
      File ".../Flask-0.11-py3.5.egg/flask/_compat.py", line 33, in reraise
        raise value
      File ".../Flask-0.11-py3.5.egg/flask/app.py", line 1988, in wsgi_app
        response = self.full_dispatch_request()
      File ".../Flask-0.11-py3.5.egg/flask/app.py", line 1642, in full_dispatch_request
        response = self.make_response(rv)
      File ".../Flask_API-0.6.6-py3.5.egg/flask_api/app.py", line 58, in make_response
        rv = self.response_class(rv, headers=headers, status=status_or_headers)
      File ".../Flask_API-0.6.6-py3.5.egg/flask_api/response.py", line 17, in __init__
        content = renderer.render(content, media_type, **options)
      File ".../Flask_API-0.6.6-py3.5.egg/flask_api/renderers.py", line 112, in render
        mock_content = html_escape(mock_content)
      File ".../Flask_API-0.6.6-py3.5.egg/flask_api/renderers.py", line 20, in html_escape
        text = text.replace(char, replacement)
    AttributeError: 'NoneType' object has no attribute 'replace'
    
    bug help wanted 
    opened by jacebrowning 3
  • How could Flask 2.x's MethodView be used with this?

    How could Flask 2.x's MethodView be used with this?

    Since Flask 2.x there has been a MethodView class that allows users to define api method-based classes for entity management. Can an example be provided showing how to use these new class-centric routes with flask-api?

    Example MethodView:

    from flask import current_app as app
    from flask.views import MethodView
    
    class ExampleEndpoint(MethodView):
        """ Example of a class inheriting from flask.views.MethodView 
    
        All 5 request methods are available at /api/example/<entity>
        """
        def get(self, entity):
            """ Responds to GET requests """
            return "Responding to a GET request"
    
        def post(self, entity):
            """ Responds to POST requests """
            return "Responding to a POST request"
    
        def put(self, entity):
            """ Responds to PUT requests """
            return "Responding to a PUT request"
    
        def patch(self, entity):
            """ Responds to PATCH requests """
            return "Responding to a PATCH request"
    
        def delete(self, entity):
            """ Responds to DELETE requests """
            return "Responding to a DELETE request"
    
    app.add_url_rule("/api/example/<entity>", view_func=ExampleEndpoint.as_view("example_api"))
    
    
    opened by caffeinatedMike 0
  • Using it with flask-restful breaks rendering

    Using it with flask-restful breaks rendering

    Hi,

    I've tried the module using traditional route definition and it works perfectly.

    But when using flask-restful to build my API, the rendering is broken and I can't longer get the browsable API. I then just have a poor text (http response) on a blank page.

    I think that's because I use classes instead of functions for my routes, with HTTP methods directly defined as route's class methods, and therefore flask-api behaves an unexpectable way for rendering.

    Has someone here tried that please?

    Regards, Eugène NG

    opened by papiveron 2
  • PUT on the browsable API renderer actually performs POST

    PUT on the browsable API renderer actually performs POST

    Given a route that accepts PUT and GET but not POST, the browsable API renderer performs a POST despite the button very clearly showing PUT.

    image image

    from flask_api import FlaskAPI
    
    app = FlaskAPI(__name__)
    
    @app.route("/", methods=["PUT", "GET"])
    def index():
        return {}
    
    if __name__ == "__main__":
        app.run(debug=True)
    

    requirements.txt

    bug help wanted 
    opened by andreareina 5
  • Use with a REST-API.

    Use with a REST-API.

    Quick question: Can I use this with a REST API? Specifically: My Own.

    opened by TechStudent11 0
  • Flask API XML output?

    Flask API XML output?

    Hello, sorry if this would not be the place to ask for help..

    But could I use Flask API for XML output?

    Any chance for how I could modify the Flask Code to Flask API?

    from flask import Flask, Response
    
    
    class MyResponse(Response):
        default_mimetype = 'application/xml'
    
    class MyFlask(Flask):
        response_class = MyResponse
    
        
    app = MyFlask(__name__)
    
    
    @app.route('/')
    def get_data():
        return '''<?xml version="1.0" encoding="UTF-8"?>
    <person>
        <name>John Smith</name>
    </person>
    '''
    
    if __name__ == '__main__':
        app.run(debug=True)
    
    
    question 
    opened by bbartling 0
  • Content negotiation ignores quality

    Content negotiation ignores quality

    The quality (q) parameter in the Accept header has no influence on the selected renderer.

    When negotiating the Content-Type of a response, each candidate is currently awarded a "precedence" based on how complete the media type is. (Fully specified types with parameters are highest, wildcards are lowest.) Even if I supply two media types with the same precedence in the Accept header, the selected type is subject to the order they are encountered while iterating the set of types of the same precedence.

    I would propose this be improved to support quality using the same rules as Apache: https://httpd.apache.org/docs/current/content-negotiation.html

    • Use quality specifier from the request if provided
    • Fully specified types are implicitly q=1.0
    • Partially specified types (text/*) are implicitly q=0.02
    • Unspecified types (*/*) are implicily q=0.01

    I am about to implement this as a custom negotiator class but will happily supply a PR if the work is warranted.

    opened by james-emerton 0
  • modified json.dumps parameters in renderers.py and set Access-Control…

    modified json.dumps parameters in renderers.py and set Access-Control…

    While calling json.dumps in renderers.py, I have changed 'ensure_ascii' to True and started passing 'default' parameter with value str. Apart from this I have set Access-Control-Allow-Origin to * in response.py, which is generally required in APIs.

    opened by aloknayak29 0
  • Accept: 'application/json; indent=4' not working.

    Accept: 'application/json; indent=4' not working.

    Hi, The header mentioned in question title is raising:
    Exception:flask_api.exceptions.NotAcceptable: Could not satisfy the request Accept header I am trying the demo app using Postman to test request. Any ideas why is this not loading JSONRenderer() object?

    EDIT: What i understand from further debugging is that select_renderer() from Class DefaultNegotiation tries to match application/json and application/json;indent=4 through satisfies() from Class Media. But server_media_type is initialized to JSONRenderer media_type attribute. I added following check to the satisfies() and it works:

    if self.full_type == other.full_type:
                return True
    

    Is this correct? Or there is some other way of doing it without modifying the code?

    help wanted 
    opened by sohaibfarooqi 1
  • No way to customize ``view_name`` in html templace

    No way to customize ``view_name`` in html templace

    Currently it's generated by simple

    def convert_to_title(name):
        return name.replace('-', ' ').replace('_', ' ').replace('.', ' ').capitalize()
    

    but for example if endpoint contains . it becomes strange

    help wanted 
    opened by bubenkoff 1
  • BrowsableAPIRenderer.render assumes url_rule is not None

    BrowsableAPIRenderer.render assumes url_rule is not None

    I've encountered this exception:

    Traceback (most recent call last):
      File "C:\Users\100496078\Source\panda-insights\panda_api\env\lib\site-packages\flask\app.py", line 1836, in __call__
        return self.wsgi_app(environ, start_response)
      File "C:\Users\100496078\Source\panda-insights\panda_api\env\lib\site-packages\flask\app.py", line 1820, in wsgi_app
        response = self.make_response(self.handle_exception(e))
      File "C:\Users\100496078\Source\panda-insights\panda_api\env\lib\site-packages\flask\app.py", line 1403, in handle_exception
        reraise(exc_type, exc_value, tb)
      File "C:\Users\100496078\Source\panda-insights\panda_api\env\lib\site-packages\flask\_compat.py", line 33, in reraise
        raise value
      File "C:\Users\100496078\Source\panda-insights\panda_api\env\lib\site-packages\flask\app.py", line 1817, in wsgi_app
        response = self.full_dispatch_request()
      File "C:\Users\100496078\Source\panda-insights\panda_api\env\lib\site-packages\flask\app.py", line 1478, in full_dispatch_request
        response = self.make_response(rv)
      File "C:\Users\100496078\Source\panda-insights\panda_api\env\lib\site-packages\flask_api\app.py", line 58, in make_response
        rv = self.response_class(rv, headers=headers, status=status_or_headers)
      File "C:\Users\100496078\Source\panda-insights\panda_api\env\lib\site-packages\flask_api\response.py", line 17, in __init__
        content = renderer.render(content, media_type, **options)
      File "C:\Users\100496078\Source\panda-insights\panda_api\env\lib\site-packages\flask_api\renderers.py", line 104, in render
        endpoint = request.url_rule.endpoint
    AttributeError: 'NoneType' object has no attribute 'endpoint'
    

    This is due to the line:

    endpoint = request.url_rule.endpoint
    

    As documented in Flask's API docs, url_rule may be None in some situations (e.g. for a 404 handler).

    Here's a simple piece of demo code to show the bug in action:

    from flask.ext.api import FlaskAPI
    
    app = FlaskAPI(__name__)
    
    @app.errorhandler(404)
    def not_found(error):
        return {}
    
    app.run(debug=True)
    
    bug help wanted 
    opened by Patman64 5
A small repository of projects built in my course, REST APIs with Flask and Python.

A small repository of projects built in my course, REST APIs with Flask and Python.

Teclado 833 Feb 22, 2022
Web APIs for Django. 🎸

Django REST framework Awesome web-browsable Web APIs. Full documentation for the project is available at https://www.django-rest-framework.org/. Fundi

Encode 22.9k Mar 3, 2022
Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.

?? Fast, Async-ready, Openapi, type hints based framework for building APIs

Vitaliy Kucheryaviy 2.6k Feb 25, 2022
Document Web APIs made with Django Rest Framework

DRF Docs Document Web APIs made with Django Rest Framework. View Demo Contributors Wanted: Do you like this project? Using it? Let's make it better! S

Manos Konstantinidis 616 Dec 18, 2021
Creating delicious APIs for Django apps since 2010.

django-tastypie Creating delicious APIs for Django apps since 2010. Currently in beta but being used actively in production on several sites. Requirem

null 3.8k Mar 1, 2022
RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

Microsoft 1.5k Feb 25, 2022
Scaffold django rest apis like a champion 🚀

scaffold django rest apis like a champion ??

Abdenasser Elidrissi 82 Feb 14, 2022
Sanic-RESTPlus is an extension for Sanic that adds support for quickly building REST APIs.

Sanic RestPlus Sanic-RESTPlus is an extension for Sanic that adds support for quickly building REST APIs. Sanic-RESTPlus encourages best practices wit

Ashley Sommer 104 Dec 6, 2021
REST API with Flask. No data persistence.

Flask REST API Python 3.9.7 The Flask experience, without data persistence :D First, to install all dependencies: python -m pip install -r requirement

Luis Quiñones Requelme 1 Dec 15, 2021
A simple API example in Python (Flask framework)

API-Example A simple API in Python(Flask) ✨ Features An API i guess? ??‍♀️ How to use first download the main.py install python then install flask fra

Portgas D Ace 2 Jan 6, 2022
A small project in Python + Flask to demonstrate how to create a REST API

SmartBed-RESTApi-Example This application is an example of how to build a REST API. The application os a mock IoT device, simulating a Smart Bed. Impl

Rares Cristea 6 Jan 28, 2022
Flask RestAPI Project - Transimage Rest API For Python

[ 이미지 변환 플라스크 Rest API ver01 ] 0. Flask Rest API - in SunnyWeb : 이미지 변환 웹의 Flask

OliverKim 1 Jan 12, 2022
The Web API toolkit. 🛠

?? The Web API toolkit. ?? Community: https://discuss.apistar.org ?? ?? ?? ?? ?? Documentation: https://docs.apistar.com ?? Requirements: Python 3.6+

Encode 5.6k Mar 2, 2022
Async Python 3.6+ web server/framework | Build fast. Run fast.

Sanic | Build fast. Run fast. Build Docs Package Support Stats Sanic is a Python 3.6+ web server and web framework that's written to go fast. It allow

Sanic Community Organization 15.9k Feb 25, 2022
A JSON Web Token authentication plugin for the Django REST Framework.

Simple JWT Abstract Simple JWT is a JSON Web Token authentication plugin for the Django REST Framework. For full documentation, visit django-rest-fram

Jazzband 2.8k Feb 23, 2022
a web-remote minecraft server wrapper with some unique features

Canceled here, continued as Semoxy MCWeb - a Minecraft Server Web Interface MCWeb is a web-remote Minecraft Server Wrapper for controlling your Minecr

Anton Vogelsang 1 Jul 12, 2021
BreakFastApi 🍣 🍔 🍕 The most delicious API on the web

BreakFastApi ?? ?? ?? The most delicious API on the web. Just send a request and you'll receive the most mouth watering dish recipe with estimated coo

Mariia Sizova 128 Feb 25, 2022
Browsable web APIs for Flask.

Flask API Browsable web APIs for Flask. Status: This project is in maintenance mode. The original author (Tom Christie) has shifted his focus to API S

Flask API 1.3k Feb 17, 2022
flask-apispec MIT flask-apispec (🥉24 · ⭐ 520) - Build and document REST APIs with Flask and apispec. MIT

flask-apispec flask-apispec is a lightweight tool for building REST APIs in Flask. flask-apispec uses webargs for request parsing, marshmallow for res

Joshua Carp 573 Feb 14, 2022
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.

Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints. check parameters and generate API documents automatically. Flask Sugar是一个基于flask,pyddantic,类型注解的API框架, 可以检查参数并自动生成API文档

null 118 Feb 19, 2022
Embrace the APIs of the future. Hug aims to make developing APIs as simple as possible, but no simpler.

Read Latest Documentation - Browse GitHub Code Repository hug aims to make developing Python driven APIs as simple as possible, but no simpler. As a r

Hug API Framework 6.6k Feb 21, 2022
Embrace the APIs of the future. Hug aims to make developing APIs as simple as possible, but no simpler.

Read Latest Documentation - Browse GitHub Code Repository hug aims to make developing Python driven APIs as simple as possible, but no simpler. As a r

Hug API Framework 6.6k Feb 21, 2022
Strong, Simple, and Precise security for Flask APIs (using jwt)

flask-praetorian Strong, Simple, and Precise security for Flask APIs API security should be strong, simple, and precise like a Roman Legionary. This p

Tucker Beck 309 Feb 18, 2022
Flask + marshmallow for beautiful APIs

Flask-Marshmallow Flask + marshmallow for beautiful APIs Flask-Marshmallow is a thin integration layer for Flask (a Python web framework) and marshmal

marshmallow-code 735 Feb 19, 2022
NO LONGER MAINTAINED - A Flask extension for creating simple ReSTful JSON APIs from SQLAlchemy models.

NO LONGER MAINTAINED This repository is no longer maintained due to lack of time. You might check out the fork https://github.com/mrevutskyi/flask-res

null 1k Feb 24, 2022
NO LONGER MAINTAINED - A Flask extension for creating simple ReSTful JSON APIs from SQLAlchemy models.

NO LONGER MAINTAINED This repository is no longer maintained due to lack of time. You might check out the fork https://github.com/mrevutskyi/flask-res

null 1k Jan 15, 2021
Strong, Simple, and Precise security for Flask APIs (using jwt)

flask-praetorian Strong, Simple, and Precise security for Flask APIs API security should be strong, simple, and precise like a Roman Legionary. This p

Tucker Beck 266 Feb 15, 2021
Flask + marshmallow for beautiful APIs

Flask-Marshmallow Flask + marshmallow for beautiful APIs Flask-Marshmallow is a thin integration layer for Flask (a Python web framework) and marshmal

marshmallow-code 659 Feb 15, 2021
Flask + marshmallow for beautiful APIs

Flask-Marshmallow Flask + marshmallow for beautiful APIs Flask-Marshmallow is a thin integration layer for Flask (a Python web framework) and marshmal

marshmallow-code 736 Feb 24, 2022