8000 Release v2.0 by jacebrowning · Pull Request #111 · flask-api/flask-api · GitHub
[go: up one dir, main page]

Skip to content

Release v2.0 #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
dist: xenial

language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
- 3.7
- 3.8

cache:
pip: true
Expand All @@ -14,8 +15,7 @@ env:
global:
- RANDOM_SEED=0
matrix:
- FLASK_VERSION=0.12.4
- FLASK_VERSION=1.0.2
- FLASK_VERSION=1.1.1

before_install:
- pip install pipenv
Expand Down 8000
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Markdown = "<3"
[dev-packages]

# Linters
flake8 = "~=2.1"
flake8 = "~=3.7.9"

# Testing
nose = "*"
Expand Down
393 changes: 216 additions & 177 deletions Pipfile.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Browsable web APIs for Flask.

[![Unix Build Status](https://img.shields.io/travis/flask-api/flask-api.svg)](https://travis-ci.org/flask-api/flask-api)
[![Unix Build Status](https://img.shields.io/travis/flask-api/flask-api.svg)](https://travis-ci.org/flask-api/flask-api)
[![Coverage Status](https://img.shields.io/coveralls/flask-api/flask-api.svg)](https://coveralls.io/r/flask-api/flask-api)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/flask-api/flask-api.svg)](https://scrutinizer-ci.com/g/flask-api/flask-api/)
[![PyPI Version](https://img.shields.io/pypi/v/Flask-API.svg)](https://pypi.org/project/Flask-API/)
Expand All @@ -19,8 +19,8 @@ Flask API is a drop-in replacement for Flask that provides an implementation of

Requirements:

* Python 2.7+ or 3.4+
* Flask 0.12.3+
* Python 3.6+
* Flask 1.1.+

Install using `pip`:

Expand All @@ -46,7 +46,7 @@ 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.
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

Expand Down Expand Up @@ -133,8 +133,8 @@ You can now open a new tab and interact with the API from the command line:

```shell
$ 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/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/
Expand Down
5 changes: 5 additions & 0 deletions docs/about/release-notes.md
< 8000 td id="diff-0dbef2eee08ae742e45363c13a338a93394f65721027aedb7b85f60818e35960L1" data-line-number="1" class="blob-num blob-num-context js-linkable-line-number">
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes

## Version 2.0

* Dropped support for Python `<3.6`.
* Dropped support for Flask `<1.1`.

## Version 1.1

* Added support for custom JSON encoders.
Expand Down
32 changes: 16 additions & 16 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Flask API is a drop-in replacement for Flask that provides an implementation of

Requirements:

* Python 2.7+ or 3.4+
* Flask 0.12.3+
* Python 3.6+
* Flask 1.1+

The following packages are optional:

Expand All @@ -39,7 +39,7 @@ Return any valid response object as normal, or return a `list` or `dict`.
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.
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

Expand All @@ -55,23 +55,23 @@ The following example demonstrates a simple API for creating, listing, updating

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():
"""
Expand All @@ -82,11 +82,11 @@ The following example demonstrates a simple API for creating, listing, updating
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):
"""
Expand All @@ -96,17 +96,17 @@ The following example demonstrates a simple API for creating, listing, updating
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)

Expand Down
2 changes: 1 addition & 1 deletion flask_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from flask_api.app import FlaskAPI

__version__ = '1.1'
__version__ = '2.0'
3 changes: 1 addition & 2 deletions flask_api/mediatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def __hash__(self):
def __eq__(self, other):
# Compare two MediaType instances, ignoring parameter ordering.
return (
self.full_type == other.full_type and
self.params == other.params
self.full_type == other.full_type and self.params == other.params
)


Expand Down
4 changes: 2 additions & 2 deletions flask_api/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def _parse(self):
try:
parser, media_type = negotiator.select_parser(parsers)
ret = parser.parse(self.stream, media_type, **options)
except:
except Exception as e:
# Ensure that accessing `request.data` again does not reraise
# the exception, so that eg exceptions can handle properly.
self._set_empty_data()
raise
raise e from None

if parser.handles_file_uploads:
assert isinstance(ret, tuple) and len(ret) == 2, 'Expected a two-tuple of (data, files)'
Expand Down
1 change: 1 addition & 0 deletions flask_api/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def is_server_error(code):
HTTP_415_UNSUPPORTED_MEDIA_TYPE = 415
HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE = 416
HTTP_417_EXPECTATION_FAILED = 417
HTTP_418_IM_A_TEAPOT = 418
HTTP_428_PRECONDITION_REQUIRED = 428
HTTP_429_TOO_MANY_REQUESTS = 429
HTTP_431_REQUEST_HEADER_FIELDS_TOO_LARGE = 431
Expand Down
10 changes: 3 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
author = 'Tom Christie'
author_email = 'tom@tomchristie.com'
license = 'BSD'
install_requires = [
'Flask >= 0.12.3',
]
install_requires = ['Flask >= 1.1']

long_description = """Browsable web APIs for Flask."""

Expand Down Expand Up @@ -75,12 +73,10 @@ def get_package_data(package):
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Internet :: WWW/HTTP',
]
)
0