23
loading...
This website collects cookies to deliver better user experience
Verb | CRUD | Operation |
---|---|---|
GET | Read | Fetch a single or multiple resource |
POST | Create | Insert a new resource |
PUT | Update/Replace | Insert new resource or update existing |
DELETE | Delete | Delete a single or multiple resource |
PATCH | Update/Modify | Only update the provided changes to the resource |
{
"ID": "1",
"Name": "Building REST APIs wiith Flask",
"Author": "@phy",
"Publisher": "Apress"
}
<?xml version="1.0" encoding="UTF-8"?>
<Book>
<ID> 1 </ID>
<Name> Building REST APIs with Flask </Name>
<Author> @phy </Author>
<Publisher > Apress </ Publisher >
</Book>
{
"ID": "1",
"Name": "Building REST APIs wiith Flask",
"Author": "@phy",
"Publisher": "Apress",
"URI" : "https://apress.com/us/book/123456789"
}
pip install flask-restful
from flask import Flask, jsonify
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class info(Resource):
def get(self):
return jsonify({'name':'Phylis',
'address':'Kenya'
})
api.add_resource(info, '/')
if __name__ == '__main__':
app.run(debug=True)
app = Flask(__name__)
api = Api(app)
class info(Resource):
def get(self):
return jsonify({'name':'Phylis',
'address':'Kenya'
})
api.add_resource(info, '/')
{"address":"Kenya","name":"Phylis"}