There is an example API working with an example database. All your application code should be written inside the ./src/ folder.
- src/main.py (it's were your endpoints should be coded)
- src/mode.py (your database tables and serialization logic)
- src/utils.py (some reusable classes and functions)
For a more detailed explanation look for the tutorial inside the docs folder.
You have to migreate and upgrade the migrations for every update your make to your models:
$ pipenv run migrate (to make the migrations)
$ pipenv run upgrade (to update your databse with the migrations)
- Make sure you have python 3.6+
$ pipenv install (to install pip packages)
$ pipenv run migrate (to create the database)
$ pipenv run start (to start the flask webserver)This template is 100% compatible with heroku, just make sure to understand and execute the following steps
- Install heroku
$ npm i heroku -g- Login to heroku on the command line
$ heroku login -i- Create an application (if you don't have it already)
$ heroku create <your_application_name>- Commit and push to heroku Make sure you have commited your changes and push to heroku
$ git push heroku master- POST
/users
BODY:
{ username: "", mail: "", password: ""}
RESPONSE:
{
"result": "ok"
}
- GET
/users
RESPONSE:
[
{ username: "", mail: "", password: "", userid:int}
{ username: "", mail: "", password: "", userid:int}
{ username: "", mail: "", password: "", userid:int}
{ username: "", mail: "", password: "", userid:int}...
]
- PUT
/users/userid
BODY:
{ field: ""}
RESPONSE:
{ username: "", mail: "", password: ""}, 200
- GET
/users/userid
RESPONSE:
[
{ username: "", mail: "", password: ""}
]
- DELETE
/users/userid
RESPONSE:
{
"result": "ok"
}
- POST
/users/login
BODY:
{ mail: "", password: ""}
RESPONSE:
{ result: true, id: int} or { result: false}
- GET
/posts
RESPONSE:
[
{ userid:int, postid:int, date: date, status:"", dogname:"", size:"", breed:"", description:"", location:"",},
{ userid:int, postid:int, date: date, status:"", dogname:"", size:"", breed:"", description:"", location:"",},
{ userid:int, postid:int, date: date, status:"", dogname:"", size:"", breed:"", description:"", location:"",}
]
- POST
/posts
BODY:
{ userid:int, status:"", dogname:"", size:"", breed:"", description:"", location:"",}
RESPONSE:
{ result: "ok"}
- PUT
/posts/postid
BODY:
{ field: ""}
RESPONSE:
{ userid:int, postid:int, date: date, status:"", dogname:"", size:"", breed:"", description:"", location:"",}, 200
- GET
/posts/postid
RESPONSE:
{ userid:int, postid:int, date: date, status:"", dogname:"", size:"", breed:"", description:"", location:"",}
- DELETE
/posts/postid
RESPONSE:
{
"result": "ok"
}
otros:
duda en consultas query y respuesta. es con post?, para login, search, posts de un usuario