The document discusses RESTful web services and the Eve framework for building them. It provides an overview of key Eve features like setting up a basic API, connecting to MongoDB, adding validation rules, embedding resources, pagination, filtering, sorting, rate limiting, file storage, and ensuring data integrity. The presentation also covers more advanced topics such as geo-spatial support, authentication, and using Eve with other data stores like SQL and Elasticsearch.
10. SETTINGS.PY
# just a couple API endpoints with no
# custom options and validation rules
DOMAIN = {
'people': {}
'books': {}
}
11. LAUNCH THE API
$ python run.py
* Running on http://127.0.0.1:5000/
12. TEST YOUR API
$ curl -i http://localhost:5000/
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": "people" },
"parent": {
"href": "127.0.0.1:5000",
"title": "home"}
}
}
13. $ curl -i http://localhost:5000/
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": "people" },
"parent": {
"href": "127.0.0.1:5000",
"title": "home"}
}
}
HATEOAS AT WORK HERE
TEST YOUR API
14. $ curl -i http://localhost:5000/
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": "people" },
"parent": {
"href": "127.0.0.1:5000",
"title": "home"}
}
}
TEST YOUR API
CLIENTS CAN EXPLORE
THE API PROGRAMMATICALLY
15. $ curl -i http://localhost:5000/
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": "people" },
"parent": {
"href": "127.0.0.1:5000",
"title": "home"}
}
}
TEST YOUR API
AND EVENTUALLY
FILL THEIR UI
16. $ curl -i http://localhost:5000/
{
"_items": [],
"_links": {
"self": {
"href": "127.0.0.1:5000/people",
"title": "people" },
"parent": {
"href": "127.0.0.1:5000",
"title": "home"}
}
}
EMTPY AS WE DIDN’T
CONNECT A DATASOURCE
TEST YOUR API
65. $ curl -X PATCH -i <url>
-H "If-Match: 206fb4a39815cc0ebf48b2b52d7…”
-d '{"firstname": "ronald"}'
HTTP/1.1 200 OK
UPDATE ALLOWED:
ETAG MATCH BETWEEN SERVER AND CLIENT
DATA INTEGRITY AND CONSISTENCY
78. SECURITY AT A GLANCE
• global authentication
• custom endpoint auth
• public enpoints and methods
• role based access control
• user restricted resource access
86. EVENT HOOKS AT A GLANCE
• POST on_insert/on_inserted
• GET on_fetch/on_fetched
• PATCH on_update/on_updated
• PUT on_replace/on_replaced
• DELETE on_delete/on_deteled
• on_pre_<method>; on_post_<method>
89. FLASK AT YOUR FINGERTIPS
from eve import Eve
app = Eve()
# add a regular Flask endpoint
@app.route('/hello')
def hello_world():
return 'Hello World!'
app.run()
90. FLASK AT YOUR FINGERTIPS
from eve import Eve
from eve.auth import requires_auth
app = Eve()
# add Eve auth to Flask endpoint
@app.route('/hello')
@requires_auth('resource')
def hello_world():
return 'Hello World!'
app.run()
101. {124: you name here}
Bryan Cattle Christoph Witzany Daniele Pizzolli
dccrazyboy Dong Wei Ming Florian Rathgeber Francisco
Corrales Morales Garrin Kimmell Gianfranco Palumbo
Jaroslav Semančík Jean Boussier John Deng Jorge Puente
Sarrín Josh Villbrandt Julien Barbot Ken Carpenter
Kevin Bowrin Kracekumar Nicolas Bazire Nicolas Carlier
Ondrej Slinták Petr Jašek Paul Doucet Robert Wlodarczyk Roberto
Pasini Ronan Delacroix Roy Smith Ryan Shea Samuel Sutch
Stanislav Heller Thomas Sileo Tomasz Jezierski Xavi Cubillas