8000 Merge pull request #111 from flask-api/release/v2.0 · flask-api/flask-api@beb2aa4 · GitHub
[go: up one dir, main page]

Skip 8000 to content

Commit beb2aa4

Browse files
authored
Merge pull request #111 from flask-api/release/v2.0
Release v2.0
2 parents ae70313 + 6566cf1 commit beb2aa4

File tree

11 files changed

+257
-217
lines changed

11 files changed

+257
-217
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
dist: xenial
2+
13
language: python
24
python:
3-
- 2.7
4-
- 3.4
5-
- 3.5
65
- 3.6
6+
- 3.7
7+
- 3.8
78

89
cache:
910
pip: true
@@ -14,8 +15,7 @@ env:
1415
global:
1516
- RANDOM_SEED=0
1617
matrix:
17-
- FLASK_VERSION=0.12.4
18-
- FLASK_VERSION=1.0.2
18+
- FLASK_VERSION=1.1.1
1919

2020
before_install:
2121
- pip install pipenv

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Markdown = "<3"
1212
[dev-packages]
1313

1414
# Linters
15-
flake8 = "~=2.1"
15+
flake8 = "~=3.7.9"
1616

1717
# Testing
1818
nose = "*"

Pipfile.lock

Lines changed: 216 additions & 177 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Browsable web APIs for Flask.
44

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

2020
Requirements:
2121

22-
* Python 2.7+ or 3.4+
23-
* Flask 0.12.3+
22+
* Python 3.6+
23+
* Flask 1.1.+
2424

2525
Install using `pip`:
2626

@@ -46,7 +46,7 @@ def example():
4646
return {'hello': 'world'}
4747
```
4848

49-
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.
49+
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.
5050

5151
## Requests
5252

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

134134
```shell
135135
$ curl -X GET http://127.0.0.1:5000/
136-
[{"url": "http://127.0.0.1:5000/0/", "text": "do the shopping"},
137-
{"url": "http://127.0.0.1:5000/1/", "text": "build the codez"},
136+
[{"url": "http://127.0.0.1:5000/0/", "text": "do the shopping"},
137+
{"url": "http://127.0.0.1:5000/1/", "text": "build the codez"},
138138
{"url": "http://127.0.0.1:5000/2/", "text": "paint the door"}]
139139

140140
$ curl -X GET http://127.0.0.1:5000/1/

docs/about/release-notes.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes
22

3+
## Version 2.0
4+
5+
* Dropped support for Python `<3.6`.
6+
* Dropped support for Flask `<1.1`.
7+
38
## Version 1.1
49

510
* Added support for custom JSON encoders.

docs/index.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Flask API is a drop-in replacement for Flask that provides an implementation of
1414

1515
Requirements:
1616

17-
* Python 2.7+ or 3.4+
18-
* Flask 0.12.3+
17+
* Python 3.6+
18+
* Flask 1.1+
1919

2020
The following packages are optional:
2121

@@ -39,7 +39,7 @@ Return any valid response object as normal, or return a `list` or `dict`.
3939
def example():
4040
return {'hello': 'world'}
4141

42-
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.
42+
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.
4343

4444
## Requests
4545

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

5656
from flask import request, url_for
5757
from flask_api import FlaskAPI, status, exceptions
58-
58+
5959
app = FlaskAPI(__name__)
60-
61-
60+
61+
6262
notes = {
6363
0: 'do the shopping',
6464
1: 'build the codez',
6565
2: 'paint the door',
6666
}
67-
67+
6868
def note_repr(key):
6969
return {
7070
'url': request.host_url.rstrip('/') + url_for('notes_detail', key=key),
7171
'text': notes[key]
7272
}
73-
74-
73+
74+
7575
@app.route("/", methods=['GET', 'POST'])
7676
def notes_list():
7777
"""
@@ -82,11 +82,11 @@ The following example demonstrates a simple API for creating, listing, updating
8282
idx = max(notes.keys()) + 1
8383
notes[idx] = note
8484
return note_repr(idx), status.HTTP_201_CREATED
85-
85+
8686
# request.method == 'GET'
8787
return [note_repr(idx) for idx in sorted(notes.keys())]
88-
89-
88+
89+
9090
@app.route("/<int:key>/", methods=['GET', 'PUT', 'DELETE'])
9191
def notes_detail(key):
9292
"""
@@ -96,17 +96,17 @@ The following example demonstrates a simple API for creating, listing, updating
9696
note = str(request.data.get('text', ''))
9797
notes[key] = note
9898
return note_repr(key)
99-
99+
100100
elif request.method == 'DELETE':
101101
notes.pop(key, None)
102102
return '', status.HTTP_204_NO_CONTENT
103-
103+
104104
# request.method == 'GET'
105105
if key not in notes:
106106
raise exceptions.NotFound()
107107
return note_repr(key)
108-
109-
108+
109+
110110
if __name__ == "__main__":
111111
app.run(debug=True)
112112

flask_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from flask_api.app import FlaskAPI
22

3-
__version__ = '1.1'
3+
__version__ = '2.0'

flask_api/mediatypes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ def __hash__(self):
8888
def __eq__(self, other):
8989
# Compare two MediaType instances, ignoring parameter ordering.
9090
return (
91-
self.full_type == other.full_type and
92-
self.params == other.params
91+
self.full_type == other.full_type and self.params == other.params
9392
)
9493

9594

flask_api/request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ def _parse(self):
5151
try:
5252
parser, media_type = negotiator.select_parser(parsers)
5353
ret = parser.parse(self.stream, media_type, **options)
54-
except:
54+
except Exception as e:
5555
# Ensure that accessing `request.data` again does not reraise
5656
# the exception, so that eg exceptions can handle properly.
5757
self._set_empty_data()
58-
raise
58+
raise e from None
5959

6060
if parser.handles_file_uploads:
6161
assert isinstance(ret, tuple) and len(ret) == 2, 'Expected a two-tuple of (data, files)'

flask_api/status.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def is_server_error(code):
6767
HTTP_415_UNSUPPORTED_MEDIA_TYPE = 415
6868
HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE = 416
6969
HTTP_417_EXPECTATION_FAILED = 417
70+
HTTP_418_IM_A_TEAPOT = 418
7071
HTTP_428_PRECONDITION_REQUIRED = 428
7172
HTTP_429_TOO_MANY_REQUESTS = 429
7273
HTTP_431_REQUEST_HEADER_FIELDS_TOO_LARGE = 431

0 commit comments

Comments
 (0)
0