Model-Based Python and Mongo DB Web Restful Service
MIT License
pip install -r requirements.txt
{
"db": {
"url" : "mongodb://localhost:27017/",
"name" :"db_name",
"user" :"",
"password" :""
}
}
collection_name = 'todos' # collection name
fields = {
"title" : "string",
"body" : "string",
"created" : "datatime"
}
create_required_fields = [] # example create_required_fields = ["title", "body"]
create_optional_fields = [] # example create_required_fields = ["created"]
update_required_fields = []
update_optional_fields = []
create_required_fields = ["title", "body"]
create_optional_fields = []
update_required_fields = ["title", "body"]
update_optional_fields = []
insert
method store data to database after confirm validation from modelfind
method retries all data from mongo databasefind_by_id
method retries back a single search dataupdate
method store updated data to database with corresponding iddelete
method delete data from database with corresponding idRequest | Endpoint | Details |
---|---|---|
GET |
http://127.0.0.1:5000/todos |
Get All |
GET |
http://127.0.0.1:5000/todos/todo_id |
Get Single Id |
POST |
http://127.0.0.1:5000/todos |
Insert One |
PUT |
http://127.0.0.1:5000/todos/todo_id |
Update One |
DELETE |
http://127.0.0.1:5000/todos/todo_id |
Delete One |
flask routes
python app.py