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'
}
```
=========================
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.
Source Distribution
File details
Details for the file flask_simplerest-1.0.3.tar.gz
.
File metadata
- Download URL: flask_simplerest-1.0.3.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7544385b9c7eead32e043ea8773f9ae1f80b09799d516002ad54da0c16271d3b |
|
MD5 | bef7ddfe45c5ad7da2d4707cb93b18a5 |
|
BLAKE2b-256 | e099ad6b27458b3b86fb5cf7e22b1b8383e804185bc34c4f311737e9ce8f229e |