diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/app.js | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/client/app.js b/client/app.js index cadafef..d18a5aa 100644 --- a/client/app.js +++ b/client/app.js @@ -4,9 +4,10 @@ import UploadImage from './lib/uploadImage.component' import { post } from './util' const initialState = { - 'image': null, - 'res': null, - 'loading': false, + image: null, + url: "", + res: null, + loading: false, } export default class PhashApp extends Component { @@ -35,6 +36,19 @@ export default class PhashApp extends Component { submit() { const { url } = this.state if (!url || url.indexOf('http') !== 0) return + this.setState({ image: url, loading: true }) + + const fd = new FormData() + fd.append('url', url) + post('/api/v1/match', fd) + .then(res => { + console.log(res) + this.setState({ res, loading: false }) + }) + .catch(err => { + console.log(err) + this.setState({ loading: false }) + }) } render() { @@ -108,10 +122,11 @@ export default class PhashApp extends Component { ) } - const { ext, phash, score, sha256 } = closest_match + const { phash, score, sha256, url} = closest_match return ( <div className='results'> - Closest match: {sha256}{'.'}{ext}<br /> + <img src={url} /><br /> + Closest match: {sha256}<br /> Score: {score}<br /> Phash: {phash.toString(16)} </div> |
