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

Skip to content

Release v1.0 #83

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 13 commits into from
Aug 29, 2017
Prev Previous commit
Next Next commit
Update docs for 1.0 release
  • Loading branch information
jacebrowning committed Aug 22, 2017
commit 5be9eea1a5e62e669bdc39ec7c59ad467b64628e
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Requirements:
* Python 2.7+ or 3.3+
* Flask 0.10+

Install using `pip`.
Install using `pip`:

pip install Flask-API

Import and initialize your application.
Import and initialize your application:

from flask_api import FlaskAPI

Expand Down
4 changes: 3 additions & 1 deletion docs/about/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Release Notes

This project is currently in beta. It is functional and well tested but you are advised to pay close attention to the release notes when upgrading to future versions.
## Version 1.0

* Stable release to enter maintenance mode.

## Version 0.7.1

Expand Down
156 changes: 60 additions & 96 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,10 @@ Browsable Web APIs for Flask

## Overview

Flask API is an implementation of the same web browsable APIs that [Django REST framework][django-rest-framework] provides.

It gives you properly content negotiated responses and smart request parsing.

It is currently a work in progress, but the fundamentals are in place and you can already start building kick-ass browsable Web APIs with it. If you want to start using Flask API right now go ahead and do so, but be sure to follow the release notes of new versions carefully.
Flask API is a drop-in replacement for Flask that provides an implementation of browsable APIs similar to what [Django REST framework](http://www.django-rest-framework.org) provides. It gives you properly content negotiated-responses and smart request parsing:

![Screenshot](screenshot.png)

## Roadmap

Future work on getting Flask API to a 1.0 release will include:

* Authentication, including session, basic and token authentication.
* Permissions, including a simple user-is-authenticated permission.
* Throttling, including a base rate throttling implementation.
* Support for using class based views, including the base view class.
* Browsable API improvements, such as breadcrumb generation.
* Customizable exception handling.
* CSRF protection for session authenticated requests.
* Login and logout views for the browsable API.
* Documentation on how to deal with request validation.
* Documentation on how to deal with hyperlinking.

It is also possible that the core of Flask API could be refactored into an external dependency, in order to make browsable APIs easily available to any Python web framework.

## Installation

Requirements:
Expand All @@ -42,14 +21,13 @@ The following packages are optional:

* Markdown (2.1.0+) - Markdown support for the browsable API.

Install using `pip`, including any optional packages you want...
Install using `pip`:

pip install Flask-API
pip install markdown # Markdown support for the browsable API.

Import and initialize your application.
Import and initialize your application:

from flask.ext.api import FlaskAPI
from flask_api import FlaskAPI

app = FlaskAPI(__name__)

Expand All @@ -75,62 +53,62 @@ Access the parsed request data using `request.data`. This will handle JSON or f

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

from flask import request, url_for
from flask.ext.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)
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:

Expand All @@ -148,17 +126,3 @@ You can now open a new tab and interact with the API from the command line:
{"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.

## Credits

To stay up to date with progress on Flask API, follow Tom Christie on twitter, [here][tomchristie].

Many thanks to [Nicolas Clairon][nicolas-clarion] for making the `flask_api` PyPI package available.

[travis-image]: https://travis-ci.org/tomchristie/flask-api.png?branch=master
[travis-link]: https://travis-ci.org/tomchristie/flask-api
[coveralls-image]: https://coveralls.io/repos/tomchristie/flask-api/badge.png?branch=master
[coveralls-link]: https://coveralls.io/r/tomchristie/flask-api?branch=master
[django-rest-framework]: http://www.django-rest-framework.org
[tomchristie]: https://twitter.com/_tomchristie
[nicolas-clarion]: https://github.com/namlook/
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__ = '0.7.1'
__version__ = '1.0b1'
13 changes: 1 addition & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ def get_package_data(package):
for filename in filenames])
return {package: filepaths}


if sys.argv[-1] == 'publish':
os.system("git clean -xdf")
os.system("python setup.py sdist upload")
args = {'version': get_version(package)}
print("You probably want to also tag the version now:")
print(" git tag -a %(version)s -m 'version %(version)s'" % args)
print(" git push --tags")
sys.exit()


setup(
name=name,
version=get_version(package),
Expand All @@ -78,7 +67,7 @@ def get_package_data(package):
package_data=get_package_data(package),
install_requires=install_requires,
classifiers=[
'Development Status :: 4 - Beta',
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Flask',
'Intended Audience :: Developers',
Expand Down
0