FacialRecognition-Demo/application/endpoints.py

58 lines
1.8 KiB
Python
Raw Normal View History

2020-03-15 19:02:37 +00:00
from flask_restful import Resource, reqparse
import flask
import requests
import application.config as config
import json
2020-03-15 22:15:40 +00:00
from application.db import Session, Person, Fingerprint
2020-03-15 19:02:37 +00:00
class PersonList(Resource):
def post(self, id):
""" """
try:
data = ""
return flask.make_response(flask.jsonify({'data': data}), 201)
except Exception as e:
print("error: -", e)
return flask.make_response(flask.jsonify({'error': str(e)}), 400)
def get(self, id):
""" """
try:
session = Session()
2020-03-15 22:15:40 +00:00
fingerprint = Fingerprint(fingerprint_id=1)
person = Person(fname="hi", fingerprints=[fingerprint])
session.add(fingerprint)
2020-03-15 19:02:37 +00:00
session.add(person)
2020-03-15 22:15:40 +00:00
2020-03-15 19:02:37 +00:00
session.commit()
data = list(session.query(Person).all())
arr = []
for x in data:
2020-03-15 22:15:40 +00:00
arr.append(x.serialize())
2020-03-15 19:02:37 +00:00
print(arr)
return flask.make_response(flask.jsonify({'data': arr}), 200)
except Exception as e:
print("error: -", e)
return flask.make_response(flask.jsonify({'error': str(e)}), 400)
def put(self, id):
""" """
try:
data = ""
return flask.make_response(flask.jsonify({'data': data}), 200)
except Exception as e:
print("error: -", e)
return flask.make_response(flask.jsonify({'error': str(e)}), 400)
def delete(self, id):
""" """
try:
data = ""
return flask.make_response(flask.jsonify({'data': data}), 204)
except Exception as e:
print("error: -", e)
return flask.make_response(flask.jsonify({'error': str(e)}), 400)