def post(): """ Insert a new record :return: insert time """ json = request.get_json() current_datetime = datetime.datetime.now() try: visit = Counter(date_time=current_datetime, agency_id=json["agency_id"]) except KeyError: return {"error": "Lack necessary argument"}, 406 db.session.add(visit) db.session.commit() count = len(Counter.query.filter_by(agency_id=json["agency_id"]).all()) return {"count": count}, 201
def post(self, _to): data = self.parser.parse_args() counter = Counter.find_counter(_to=_to) count = data["increase_by"] print("coutner", counter) print("count", count) if counter is not None: print("eyo") count += counter.count counter.delete_from_db() thought = Counter(_to, count) try: thought.save_to_db() except: return { "message": "An error occurred while saving the item (count) to the database." }, 500 return {"message": "Count increased"}, 200