Skip to main content

A Flask extension for easy ReSTful API generation

Project description

Flask simple REST
=========================

A Flask extansion for simple ReSTful api generation

Install
-------

For install you can use pip:
```
pip install flask_simplerest
```

Usage
-------

app.py
```
from flask import Flask
from flask.ext.simplerest import SimpleRestApp
from handlers.myhandler import MyHandler

app = Flask(__name__)
rest = SimpleRestApp(app)

MyHandler(rest, 'prefix_if_needed')

@rest('/index', 'PUT')
def some_put_method():
pass

app.run()
```

handlers/myhandler.py
```
from flask.ext.simplerest import SimpleRestResource, rest
from flask.ext.simplerest import fields

class Projects(SimpleRestResource):
@rest('/', 'POST')
def test(self, name=fields.String):
return {'name':name}

@rest('/<int:my_id>/123', 'POST')
def test2(self, my_id, name=fields.String(default='Costos')):
return dict(my_id=my_id, name=name)

```

Bash
(first you must run application)
```
curl http://127.0.0.1:5000/ -d name=Murza
{
'name': 'Murza'
}
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask_simplerest, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size flask_simplerest-1.0.3.tar.gz (3.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page