diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2019-04-27 00:25:09 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2019-04-27 00:25:09 +0200 |
| commit | a0e583ee4eebe37db4011a99b65d0d60db324054 (patch) | |
| tree | 51845a417f2998719160f7815d3f1f4fe8e89f20 /client | |
| parent | 8e9214f5d4d2a725eecdb11368451d99168ae240 (diff) | |
api now fetches url
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> |
