summaryrefslogtreecommitdiff
path: root/check/app/server/api.py
blob: 12d955b7e228f3564463417b7caccca37f592f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import re
import time
import numpy as np
from flask import Blueprint, request, jsonify
from PIL import Image

# from app.utils.im_utils import pil2np
from app.models.sql_factory import search_by_phash, add_phash

sanitize_re = re.compile('[\W]+')
valid_exts = ['.gif', '.jpg', '.jpeg', '.png']

LIMIT = 9

api = Blueprint('api', __name__)

@api.route('/')
def index():
  """API status noop"""
  return jsonify({ 'status': 'ok' })

@api.route('/v1/match/', methods=['POST'])
def upload():
  """Search by image"""
  start = time.time()
  # get threshold
  return jsonify({ 'status': 'ok' })