a template for creating API's on heroku
- Easily Create Secure and Non-Secure Endpoints
- Effortlessly Manage Get, Post, Put, Patch, and Delete Requests
- Simple tests for your API before pushing to production
- clone this repo
- cd into cloned repo
- pip install pipenv
- pipenv install
run a local API server
- python run.py
run tests via pytest to verify request endpoints are working
- pytest -v
- pipenv install
all endpoint development should happen in routing.py under app
you can easily build each endpoint as its own class
# this wrapper automatically adds the endpoints to the rest API
@rest_resource
# create a request class that wraps a Secure or NonSecure base class
class BasicRequest(NonSecure):
# the endpoint for the request
endpoints = ['/api']
# the type of request
def get(self):
# return something
return jsonify(dict(message="Successful Get Request Made!"))
@rest_resource
class BasicRequest(Secure):
# request must have an Authorization header!
endpoints = ['/api']
def post(self):
if request.data:
return jsonify(request.json)
else:
return abort(400, message='Please Send Data!')