def index(): if rq.method=="POST": barcodeData=" " barcodeType=" " for i in decode(img.open(rq.files["barcode"].stream)): barcodeData=i.data.decode("utf-8") barcodeType = i.type return js(barcodeData=barcodeData,barcodeType= barcodeType)
def home(): if rq.method=="POST": qr=" " for i in decode(img.open(rq.files["qr"].stream)): # or rq.files["qr"] qr=i.data.decode("utf-8") return js(qr=qr)
def index(): return js({"data": "Hello World!"})
def edit_user(id): user = User.query.get_or_404(id) user.import_data(request.json) db.session.add(user) db.session.commit() return js({})
def create_user(): user = User() user.import_data(request.json) db.session.add(user) db.session.commit() return js({}), 201, {'Location': 'user.get_url()'}
def get_user(id): return js(User.query.get_or_404(id).export_data())
def list_users(): all_users = User.query.all() url_list = [user_url.get_url() for user_url in all_users] return js({"users_urls": url_list })
def list_tasks(): all_tasks = Task.objects.all() url_list = [task.get_url() for task in all_tasks] return js({"tasks_urls": url_list})
def edit_task(id): task = Task.objects.get_or_404(id=id) task.import_data(request.json) task.save() return js({})
def create_task(): task = Task() task.import_data(request.json) task.save() return js({}), 201, {'Location': task.get_url()}
def get_task(id): return js(Task.objects.get_or_404(id=id).export_data())