Question
I would like some help in adding these to my code using CRUD> HOw would I go about implementing? Add the following document to the
I would like some help in adding these to my code using CRUD> HOw would I go about implementing?
"Add the following document to the collection:" curl -H "Content-Type: application/json" -X POST -d '{"id" : "10011-2017-TEST","certificate_number" : 9278833,"business_name" : "ACME TEST INC.","date" : "Feb 20 2017","result" : "No Violation Issued","sector" : "Test Retail Dealer - 101"}' http://localhost:8080/create
"Return the document found with the given business_name" curl http://localhost:8080/read?business_name="ACME TEST INC."
"Update the result value for the document with the given id string" curl http://localhost:8080/update?id="10011-2017-TEST"&result="Violation Issued"
"Delete the document with the given id string" curl http://localhost:8080/delete?id="10011-2017-TEST
CODE:
#!/usr/bin/python
import json
from bson import json_util
import bottle
from bottle import route, run, request, abort
id = 0
set up URI paths for REST service
@route('/currentTime',method='GET')
def get_currentTime():
global id
id = id + 1
try:
request.query.name
name = request.query.name
dateString=datetime.datetime.now().strftime("%Y-%m-%d")
timeString=datetime.datetime.now().strftime("%H:%M:%S")
string="{\"date\":"+dateString+",\"time\":"+timeString+"}"
return json.loads(json.dumps(string,indent=4, default=json_util.default))
if__name__=='__main__': declare instance of request
#app.run(debug=True)
run(host='localhost',port=8080)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-text-image.webp)
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Step: 3
![blur-text-image](https://dsd5zvtm8ll6.cloudfront.net/includes/images/document_product_info/blur-subtext-image.webp)
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started