fixiefix
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
|
||||||
9
.htaccess
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
RewriteEngine on
|
||||||
|
RewriteCond %{HTTPS} !=on
|
||||||
|
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
|
||||||
|
PassengerEnabled on
|
||||||
|
PassengerAppEnv production
|
||||||
|
PassengerAppRoot /var/www/html
|
||||||
|
PassengerStartupFile index.js
|
||||||
|
PassengerNodejs /home/cat/.nvm/versions/node/v16.13.1/bin/node
|
||||||
|
PassengerAppType node
|
||||||
348
build/config.gypi
Normal file
|
|
@ -0,0 +1,348 @@
|
||||||
|
# Do not edit. File was generated by node-gyp's "configure" step
|
||||||
|
{
|
||||||
|
"target_defaults": {
|
||||||
|
"cflags": [],
|
||||||
|
"default_configuration": "Release",
|
||||||
|
"defines": [],
|
||||||
|
"include_dirs": [],
|
||||||
|
"libraries": []
|
||||||
|
},
|
||||||
|
"variables": {
|
||||||
|
"asan": 0,
|
||||||
|
"coverage": "false",
|
||||||
|
"dcheck_always_on": 0,
|
||||||
|
"debug_nghttp2": "false",
|
||||||
|
"debug_node": "false",
|
||||||
|
"enable_lto": "false",
|
||||||
|
"enable_pgo_generate": "false",
|
||||||
|
"enable_pgo_use": "false",
|
||||||
|
"error_on_warn": "false",
|
||||||
|
"force_dynamic_crt": 0,
|
||||||
|
"gas_version": "2.30",
|
||||||
|
"host_arch": "x64",
|
||||||
|
"icu_data_in": "../../deps/icu-tmp/icudt69l.dat",
|
||||||
|
"icu_endianness": "l",
|
||||||
|
"icu_gyp_path": "tools/icu/icu-generic.gyp",
|
||||||
|
"icu_path": "deps/icu-small",
|
||||||
|
"icu_small": "false",
|
||||||
|
"icu_ver_major": "69",
|
||||||
|
"is_debug": 0,
|
||||||
|
"llvm_version": "0.0",
|
||||||
|
"napi_build_version": "8",
|
||||||
|
"node_byteorder": "little",
|
||||||
|
"node_debug_lib": "false",
|
||||||
|
"node_enable_d8": "false",
|
||||||
|
"node_install_npm": "true",
|
||||||
|
"node_library_files": [
|
||||||
|
"lib/_stream_transform.js",
|
||||||
|
"lib/http.js",
|
||||||
|
"lib/querystring.js",
|
||||||
|
"lib/_http_outgoing.js",
|
||||||
|
"lib/_http_server.js",
|
||||||
|
"lib/_stream_wrap.js",
|
||||||
|
"lib/_http_common.js",
|
||||||
|
"lib/_stream_writable.js",
|
||||||
|
"lib/net.js",
|
||||||
|
"lib/console.js",
|
||||||
|
"lib/constants.js",
|
||||||
|
"lib/perf_hooks.js",
|
||||||
|
"lib/string_decoder.js",
|
||||||
|
"lib/https.js",
|
||||||
|
"lib/wasi.js",
|
||||||
|
"lib/module.js",
|
||||||
|
"lib/tty.js",
|
||||||
|
"lib/process.js",
|
||||||
|
"lib/_http_agent.js",
|
||||||
|
"lib/_http_incoming.js",
|
||||||
|
"lib/sys.js",
|
||||||
|
"lib/assert.js",
|
||||||
|
"lib/buffer.js",
|
||||||
|
"lib/child_process.js",
|
||||||
|
"lib/cluster.js",
|
||||||
|
"lib/crypto.js",
|
||||||
|
"lib/zlib.js",
|
||||||
|
"lib/dns.js",
|
||||||
|
"lib/events.js",
|
||||||
|
"lib/fs.js",
|
||||||
|
"lib/url.js",
|
||||||
|
"lib/domain.js",
|
||||||
|
"lib/_tls_common.js",
|
||||||
|
"lib/punycode.js",
|
||||||
|
"lib/vm.js",
|
||||||
|
"lib/_http_client.js",
|
||||||
|
"lib/_tls_wrap.js",
|
||||||
|
"lib/os.js",
|
||||||
|
"lib/path.js",
|
||||||
|
"lib/readline.js",
|
||||||
|
"lib/repl.js",
|
||||||
|
"lib/inspector.js",
|
||||||
|
"lib/v8.js",
|
||||||
|
"lib/_stream_passthrough.js",
|
||||||
|
"lib/_stream_readable.js",
|
||||||
|
"lib/stream.js",
|
||||||
|
"lib/timers.js",
|
||||||
|
"lib/tls.js",
|
||||||
|
"lib/trace_events.js",
|
||||||
|
"lib/worker_threads.js",
|
||||||
|
"lib/http2.js",
|
||||||
|
"lib/util.js",
|
||||||
|
"lib/dgram.js",
|
||||||
|
"lib/diagnostics_channel.js",
|
||||||
|
"lib/_stream_duplex.js",
|
||||||
|
"lib/async_hooks.js",
|
||||||
|
"lib/fs/promises.js",
|
||||||
|
"lib/stream/consumers.js",
|
||||||
|
"lib/stream/promises.js",
|
||||||
|
"lib/stream/web.js",
|
||||||
|
"lib/internal/assert.js",
|
||||||
|
"lib/internal/validators.js",
|
||||||
|
"lib/internal/constants.js",
|
||||||
|
"lib/internal/dtrace.js",
|
||||||
|
"lib/internal/options.js",
|
||||||
|
"lib/internal/js_stream_socket.js",
|
||||||
|
"lib/internal/fixed_queue.js",
|
||||||
|
"lib/internal/heap_utils.js",
|
||||||
|
"lib/internal/priority_queue.js",
|
||||||
|
"lib/internal/socketaddress.js",
|
||||||
|
"lib/internal/socket_list.js",
|
||||||
|
"lib/internal/error_serdes.js",
|
||||||
|
"lib/internal/repl.js",
|
||||||
|
"lib/internal/async_hooks.js",
|
||||||
|
"lib/internal/timers.js",
|
||||||
|
"lib/internal/tty.js",
|
||||||
|
"lib/internal/util.js",
|
||||||
|
"lib/internal/trace_events_async_hooks.js",
|
||||||
|
"lib/internal/freeze_intrinsics.js",
|
||||||
|
"lib/internal/histogram.js",
|
||||||
|
"lib/internal/http.js",
|
||||||
|
"lib/internal/idna.js",
|
||||||
|
"lib/internal/url.js",
|
||||||
|
"lib/internal/blocklist.js",
|
||||||
|
"lib/internal/encoding.js",
|
||||||
|
"lib/internal/linkedlist.js",
|
||||||
|
"lib/internal/freelist.js",
|
||||||
|
"lib/internal/watchdog.js",
|
||||||
|
"lib/internal/inspector_async_hook.js",
|
||||||
|
"lib/internal/querystring.js",
|
||||||
|
"lib/internal/v8_prof_polyfill.js",
|
||||||
|
"lib/internal/v8_prof_processor.js",
|
||||||
|
"lib/internal/net.js",
|
||||||
|
"lib/internal/cli_table.js",
|
||||||
|
"lib/internal/stream_base_commons.js",
|
||||||
|
"lib/internal/buffer.js",
|
||||||
|
"lib/internal/dgram.js",
|
||||||
|
"lib/internal/event_target.js",
|
||||||
|
"lib/internal/worker.js",
|
||||||
|
"lib/internal/child_process.js",
|
||||||
|
"lib/internal/errors.js",
|
||||||
|
"lib/internal/blob.js",
|
||||||
|
"lib/internal/abort_controller.js",
|
||||||
|
"lib/internal/assert/assertion_error.js",
|
||||||
|
"lib/internal/assert/calltracker.js",
|
||||||
|
"lib/internal/bootstrap/environment.js",
|
||||||
|
"lib/internal/bootstrap/loaders.js",
|
||||||
|
"lib/internal/bootstrap/node.js",
|
||||||
|
"lib/internal/bootstrap/pre_execution.js",
|
||||||
|
"lib/internal/bootstrap/switches/does_not_own_process_state.js",
|
||||||
|
"lib/internal/bootstrap/switches/is_not_main_thread.js",
|
||||||
|
"lib/internal/bootstrap/switches/does_own_process_state.js",
|
||||||
|
"lib/internal/bootstrap/switches/is_main_thread.js",
|
||||||
|
"lib/internal/child_process/serialization.js",
|
||||||
|
"lib/internal/cluster/shared_handle.js",
|
||||||
|
"lib/internal/cluster/child.js",
|
||||||
|
"lib/internal/cluster/primary.js",
|
||||||
|
"lib/internal/cluster/utils.js",
|
||||||
|
"lib/internal/cluster/worker.js",
|
||||||
|
"lib/internal/cluster/round_robin_handle.js",
|
||||||
|
"lib/internal/console/global.js",
|
||||||
|
"lib/internal/console/constructor.js",
|
||||||
|
"lib/internal/crypto/aes.js",
|
||||||
|
"lib/internal/crypto/certificate.js",
|
||||||
|
"lib/internal/crypto/cipher.js",
|
||||||
|
"lib/internal/crypto/diffiehellman.js",
|
||||||
|
"lib/internal/crypto/dsa.js",
|
||||||
|
"lib/internal/crypto/ec.js",
|
||||||
|
"lib/internal/crypto/hash.js",
|
||||||
|
"lib/internal/crypto/hashnames.js",
|
||||||
|
"lib/internal/crypto/hkdf.js",
|
||||||
|
"lib/internal/crypto/keygen.js",
|
||||||
|
"lib/internal/crypto/keys.js",
|
||||||
|
"lib/internal/crypto/mac.js",
|
||||||
|
"lib/internal/crypto/pbkdf2.js",
|
||||||
|
"lib/internal/crypto/random.js",
|
||||||
|
"lib/internal/crypto/rsa.js",
|
||||||
|
"lib/internal/crypto/scrypt.js",
|
||||||
|
"lib/internal/crypto/sig.js",
|
||||||
|
"lib/internal/crypto/util.js",
|
||||||
|
"lib/internal/crypto/webcrypto.js",
|
||||||
|
"lib/internal/crypto/x509.js",
|
||||||
|
"lib/internal/dns/promises.js",
|
||||||
|
"lib/internal/dns/utils.js",
|
||||||
|
"lib/internal/fs/utils.js",
|
||||||
|
"lib/internal/fs/watchers.js",
|
||||||
|
"lib/internal/fs/promises.js",
|
||||||
|
"lib/internal/fs/rimraf.js",
|
||||||
|
"lib/internal/fs/streams.js",
|
||||||
|
"lib/internal/fs/dir.js",
|
||||||
|
"lib/internal/fs/read_file_context.js",
|
||||||
|
"lib/internal/fs/sync_write_stream.js",
|
||||||
|
"lib/internal/fs/cp/cp-sync.js",
|
||||||
|
"lib/internal/fs/cp/cp.js",
|
||||||
|
"lib/internal/http2/compat.js",
|
||||||
|
"lib/internal/http2/util.js",
|
||||||
|
"lib/internal/http2/core.js",
|
||||||
|
"lib/internal/main/check_syntax.js",
|
||||||
|
"lib/internal/main/eval_stdin.js",
|
||||||
|
"lib/internal/main/prof_process.js",
|
||||||
|
"lib/internal/main/run_main_module.js",
|
||||||
|
"lib/internal/main/print_help.js",
|
||||||
|
"lib/internal/main/repl.js",
|
||||||
|
"lib/internal/main/eval_string.js",
|
||||||
|
"lib/internal/main/inspect.js",
|
||||||
|
"lib/internal/main/worker_thread.js",
|
||||||
|
"lib/internal/modules/package_json_reader.js",
|
||||||
|
"lib/internal/modules/run_main.js",
|
||||||
|
"lib/internal/modules/cjs/helpers.js",
|
||||||
|
"lib/internal/modules/cjs/loader.js",
|
||||||
|
"lib/internal/modules/esm/translators.js",
|
||||||
|
"lib/internal/modules/esm/create_dynamic_module.js",
|
||||||
|
"lib/internal/modules/esm/get_format.js",
|
||||||
|
"lib/internal/modules/esm/get_source.js",
|
||||||
|
"lib/internal/modules/esm/load.js",
|
||||||
|
"lib/internal/modules/esm/loader.js",
|
||||||
|
"lib/internal/modules/esm/module_job.js",
|
||||||
|
"lib/internal/modules/esm/module_map.js",
|
||||||
|
"lib/internal/modules/esm/resolve.js",
|
||||||
|
"lib/internal/per_context/domexception.js",
|
||||||
|
"lib/internal/per_context/messageport.js",
|
||||||
|
"lib/internal/per_context/primordials.js",
|
||||||
|
"lib/internal/policy/sri.js",
|
||||||
|
"lib/internal/policy/manifest.js",
|
||||||
|
"lib/internal/process/policy.js",
|
||||||
|
"lib/internal/process/worker_thread_only.js",
|
||||||
|
"lib/internal/process/esm_loader.js",
|
||||||
|
"lib/internal/process/promises.js",
|
||||||
|
"lib/internal/process/report.js",
|
||||||
|
"lib/internal/process/signal.js",
|
||||||
|
"lib/internal/process/task_queues.js",
|
||||||
|
"lib/internal/process/warning.js",
|
||||||
|
"lib/internal/process/execution.js",
|
||||||
|
"lib/internal/process/per_thread.js",
|
||||||
|
"lib/internal/readline/utils.js",
|
||||||
|
"lib/internal/readline/callbacks.js",
|
||||||
|
"lib/internal/readline/emitKeypressEvents.js",
|
||||||
|
"lib/internal/repl/history.js",
|
||||||
|
"lib/internal/repl/await.js",
|
||||||
|
"lib/internal/repl/utils.js",
|
||||||
|
"lib/internal/source_map/source_map_cache.js",
|
||||||
|
"lib/internal/source_map/prepare_stack_trace.js",
|
||||||
|
"lib/internal/source_map/source_map.js",
|
||||||
|
"lib/internal/streams/legacy.js",
|
||||||
|
"lib/internal/streams/passthrough.js",
|
||||||
|
"lib/internal/streams/compose.js",
|
||||||
|
"lib/internal/streams/duplex.js",
|
||||||
|
"lib/internal/streams/end-of-stream.js",
|
||||||
|
"lib/internal/streams/readable.js",
|
||||||
|
"lib/internal/streams/utils.js",
|
||||||
|
"lib/internal/streams/buffer_list.js",
|
||||||
|
"lib/internal/streams/from.js",
|
||||||
|
"lib/internal/streams/lazy_transform.js",
|
||||||
|
"lib/internal/streams/state.js",
|
||||||
|
"lib/internal/streams/add-abort-signal.js",
|
||||||
|
"lib/internal/streams/destroy.js",
|
||||||
|
"lib/internal/streams/duplexify.js",
|
||||||
|
"lib/internal/streams/pipeline.js",
|
||||||
|
"lib/internal/streams/transform.js",
|
||||||
|
"lib/internal/streams/writable.js",
|
||||||
|
"lib/internal/test/binding.js",
|
||||||
|
"lib/internal/test/transfer.js",
|
||||||
|
"lib/internal/util/comparisons.js",
|
||||||
|
"lib/internal/util/debuglog.js",
|
||||||
|
"lib/internal/util/inspector.js",
|
||||||
|
"lib/internal/util/iterable_weak_map.js",
|
||||||
|
"lib/internal/util/types.js",
|
||||||
|
"lib/internal/util/inspect.js",
|
||||||
|
"lib/internal/vm/module.js",
|
||||||
|
"lib/internal/worker/io.js",
|
||||||
|
"lib/internal/worker/js_transferable.js",
|
||||||
|
"lib/internal/tls/parse-cert-string.js",
|
||||||
|
"lib/internal/tls/secure-context.js",
|
||||||
|
"lib/internal/tls/secure-pair.js",
|
||||||
|
"lib/internal/webstreams/encoding.js",
|
||||||
|
"lib/internal/webstreams/queuingstrategies.js",
|
||||||
|
"lib/internal/webstreams/transfer.js",
|
||||||
|
"lib/internal/webstreams/transformstream.js",
|
||||||
|
"lib/internal/webstreams/util.js",
|
||||||
|
"lib/internal/webstreams/writablestream.js",
|
||||||
|
"lib/internal/webstreams/readablestream.js",
|
||||||
|
"lib/internal/debugger/inspect_repl.js",
|
||||||
|
"lib/internal/debugger/inspect.js",
|
||||||
|
"lib/internal/debugger/inspect_client.js",
|
||||||
|
"lib/internal/legacy/processbinding.js",
|
||||||
|
"lib/internal/perf/event_loop_delay.js",
|
||||||
|
"lib/internal/perf/event_loop_utilization.js",
|
||||||
|
"lib/internal/perf/nodetiming.js",
|
||||||
|
"lib/internal/perf/observe.js",
|
||||||
|
"lib/internal/perf/performance.js",
|
||||||
|
"lib/internal/perf/performance_entry.js",
|
||||||
|
"lib/internal/perf/timerify.js",
|
||||||
|
"lib/internal/perf/utils.js",
|
||||||
|
"lib/internal/perf/usertiming.js",
|
||||||
|
"lib/dns/promises.js",
|
||||||
|
"lib/path/posix.js",
|
||||||
|
"lib/path/win32.js",
|
||||||
|
"lib/timers/promises.js",
|
||||||
|
"lib/util/types.js",
|
||||||
|
"lib/assert/strict.js"
|
||||||
|
],
|
||||||
|
"node_module_version": 93,
|
||||||
|
"node_no_browser_globals": "false",
|
||||||
|
"node_prefix": "/",
|
||||||
|
"node_release_urlbase": "https://nodejs.org/download/release/",
|
||||||
|
"node_section_ordering_info": "",
|
||||||
|
"node_shared": "false",
|
||||||
|
"node_shared_brotli": "false",
|
||||||
|
"node_shared_cares": "false",
|
||||||
|
"node_shared_http_parser": "false",
|
||||||
|
"node_shared_libuv": "false",
|
||||||
|
"node_shared_nghttp2": "false",
|
||||||
|
"node_shared_nghttp3": "false",
|
||||||
|
"node_shared_ngtcp2": "false",
|
||||||
|
"node_shared_openssl": "false",
|
||||||
|
"node_shared_zlib": "false",
|
||||||
|
"node_tag": "",
|
||||||
|
"node_target_type": "executable",
|
||||||
|
"node_use_bundled_v8": "true",
|
||||||
|
"node_use_dtrace": "false",
|
||||||
|
"node_use_etw": "false",
|
||||||
|
"node_use_node_code_cache": "true",
|
||||||
|
"node_use_node_snapshot": "true",
|
||||||
|
"node_use_openssl": "true",
|
||||||
|
"node_use_v8_platform": "true",
|
||||||
|
"node_with_ltcg": "false",
|
||||||
|
"node_without_node_options": "false",
|
||||||
|
"openssl_fips": "",
|
||||||
|
"openssl_is_fips": "false",
|
||||||
|
"openssl_quic": "true",
|
||||||
|
"ossfuzz": "false",
|
||||||
|
"shlib_suffix": "so.93",
|
||||||
|
"target_arch": "x64",
|
||||||
|
"v8_enable_31bit_smis_on_64bit_arch": 0,
|
||||||
|
"v8_enable_gdbjit": 0,
|
||||||
|
"v8_enable_i18n_support": 1,
|
||||||
|
"v8_enable_inspector": 1,
|
||||||
|
"v8_enable_lite_mode": 0,
|
||||||
|
"v8_enable_object_print": 1,
|
||||||
|
"v8_enable_pointer_compression": 0,
|
||||||
|
"v8_enable_webassembly": 1,
|
||||||
|
"v8_no_strict_aliasing": 1,
|
||||||
|
"v8_optimized_debug": 1,
|
||||||
|
"v8_promise_internal_field_count": 1,
|
||||||
|
"v8_random_seed": 0,
|
||||||
|
"v8_trace_maps": 0,
|
||||||
|
"v8_use_siphash": 1,
|
||||||
|
"want_separate_host_toolset": 0,
|
||||||
|
"nodedir": "/home/harrison/.cache/node-gyp/16.13.1",
|
||||||
|
"standalone_static_library": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
199
index.js
|
|
@ -1,67 +1,54 @@
|
||||||
const express = require('express');
|
const express = require("express");
|
||||||
const path = require('path');
|
const path = require("path");
|
||||||
const bb = require('express-busboy');
|
const bb = require("express-busboy");
|
||||||
const multer = require('multer');
|
const multer = require("multer");
|
||||||
const tf = require('@tensorflow/tfjs')
|
const tf = require("@tensorflow/tfjs-node");
|
||||||
const tfn = require('@tensorflow/tfjs-node')
|
const mobilenet = require("@tensorflow-models/mobilenet");
|
||||||
const mobilenet = require('@tensorflow-models/mobilenet');
|
const fs = require("fs");
|
||||||
const fs = require('fs');
|
const jpeg = require("jpeg-js");
|
||||||
const jpeg = require('jpeg-js');
|
|
||||||
|
|
||||||
|
|
||||||
//init app
|
//init app
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bb.extend(app, {
|
bb.extend(app, {
|
||||||
upload: true,
|
upload: true,
|
||||||
path: './public/uploads/',
|
path: "./public/uploads/",
|
||||||
allowedPath: /./
|
allowedPath: /./
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var temp;
|
||||||
|
|
||||||
var temp
|
|
||||||
async function catdetector(imagePath) {
|
async function catdetector(imagePath) {
|
||||||
const image = fs.readFileSync(imagePath.toString());
|
const image = fs.readFileSync(imagePath.toString());
|
||||||
const decodedImage = tfn.node.decodeImage(image, 3);
|
const decodedImage = tf.node.decodeImage(image, 3);
|
||||||
|
|
||||||
const model = await mobilenet.load();
|
const model = await mobilenet.load({
|
||||||
|
version: 2,
|
||||||
|
alpha: 1.0
|
||||||
|
});
|
||||||
const predictions = await model.classify(decodedImage);
|
const predictions = await model.classify(decodedImage);
|
||||||
return (predictions);
|
return predictions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const storage = multer.diskStorage({
|
const storage = multer.diskStorage({
|
||||||
destination: function(req, res, cb) {
|
destination: function(req, res, cb) {
|
||||||
cb(null, './public/uploads/')
|
cb(null, "./public/uploads/");
|
||||||
},
|
},
|
||||||
filename: function(req, file, cb) {
|
filename: function(req, file, cb) {
|
||||||
cb(null, 'asdf' + path.extname(file.originalname));
|
cb(null, "asdf" + path.extname(file.originalname));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const upload = multer({
|
const upload = multer({
|
||||||
storage: storage,
|
storage: storage,
|
||||||
fileFilter: function(req, file, cb) {
|
fileFilter: function(req, file, cb) {
|
||||||
checkFileType(file, cb)
|
checkFileType(file, cb);
|
||||||
}
|
}
|
||||||
}).single('file');
|
}).single("file");
|
||||||
|
|
||||||
|
|
||||||
function move(oldPath, newPath, callback) {
|
function move(oldPath, newPath, callback) {
|
||||||
|
|
||||||
fs.rename(oldPath, newPath, function(err) {
|
fs.rename(oldPath, newPath, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.code === 'EXDEV') {
|
if (err.code === "EXDEV") {
|
||||||
copy();
|
copy();
|
||||||
} else {
|
} else {
|
||||||
callback(err);
|
callback(err);
|
||||||
|
|
@ -75,10 +62,10 @@ function move(oldPath, newPath, callback) {
|
||||||
var readStream = fs.createReadStream(oldPath);
|
var readStream = fs.createReadStream(oldPath);
|
||||||
var writeStream = fs.createWriteStream(newPath);
|
var writeStream = fs.createWriteStream(newPath);
|
||||||
|
|
||||||
readStream.on('error', callback);
|
readStream.on("error", callback);
|
||||||
writeStream.on('error', callback);
|
writeStream.on("error", callback);
|
||||||
|
|
||||||
readStream.on('close', function () {
|
readStream.on("close", function() {
|
||||||
fs.unlink(oldPath, callback.toString());
|
fs.unlink(oldPath, callback.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -86,111 +73,123 @@ function move(oldPath, newPath, callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.post('/upload', upload, function(req,res){
|
app.post("/upload", upload, function(req, res) {
|
||||||
var id = req.params.id;
|
var id = req.params.id;
|
||||||
var dir = req.files.upload;
|
var dir = req.files.upload;
|
||||||
var filecheck = req.files.file;
|
var filecheck = req.files.file;
|
||||||
var notdetected = 0;
|
var notdetected = 0;
|
||||||
const detection = new Promise((resolve, reject) => {
|
const detection = new Promise((resolve, reject) => {
|
||||||
if (filecheck.mimetype == "image/png" || filecheck.mimetype == "image/jpg" || filecheck.mimetype == "image/jpeg") {
|
if (
|
||||||
|
filecheck.mimetype == "image/png" ||
|
||||||
|
filecheck.mimetype == "image/jpg" ||
|
||||||
|
filecheck.mimetype == "image/jpeg"
|
||||||
|
) {
|
||||||
const data = catdetector(req.files.file.file);
|
const data = catdetector(req.files.file.file);
|
||||||
resolve(data);
|
resolve(data);
|
||||||
} else resolve(null);
|
} else resolve(null);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
if (filecheck == undefined) {
|
if (filecheck == undefined) {
|
||||||
res.redirect('/')
|
res.redirect("/");
|
||||||
} else {
|
} else {
|
||||||
var ext = path.parse(req.files.file.filename).ext;
|
var ext = path.parse(req.files.file.filename).ext;
|
||||||
detection.then((result) => {
|
detection.then(result => {
|
||||||
var string;
|
var string;
|
||||||
for (const i in result) {
|
for (const i in result) {
|
||||||
string += JSON.stringify(result[i])
|
string += JSON.stringify(result[i]);
|
||||||
}
|
}
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
fs.rmdir('./public/uploads/' +req.files.file.uuid, {recursive: true}, function(err){
|
fs.rmdir(
|
||||||
|
"./public/uploads/" + req.files.file.uuid,
|
||||||
|
{ recursive: true },
|
||||||
|
function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
//punchsand
|
//punchsand
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
res.redirect('/nottodaybatman')
|
);
|
||||||
}else if(string.indexOf('cat') != -1){
|
res.redirect("/nottodaybatman");
|
||||||
|
} else if (string.indexOf("cat") != -1) {
|
||||||
move(req.files.file.file , 'public/uploads/cats/'+ Date.now() + ext, function (err) {
|
move(
|
||||||
|
req.files.file.file,
|
||||||
|
"public/uploads/cats/" + Date.now() + ext,
|
||||||
|
function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
fs.rmdir('./public/uploads/' +req.files.file.uuid, {recursive: true}, function(err){
|
);
|
||||||
|
fs.rmdir(
|
||||||
|
"./public/uploads/" + req.files.file.uuid,
|
||||||
|
{ recursive: true },
|
||||||
|
function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
//punchsand
|
//punchsand
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
res.redirect('/minebitch')
|
);
|
||||||
|
res.redirect("/minebitch");
|
||||||
} else {
|
} else {
|
||||||
console.log('fail');
|
console.log("fail");
|
||||||
move(req.files.file.file , 'public/uploads/bin/'+ Date.now() + ext, function (err) {
|
move(
|
||||||
|
req.files.file.file,
|
||||||
|
"public/uploads/bin/" + Date.now() + ext,
|
||||||
|
function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
fs.rmdir('./public/uploads/' +req.files.file.uuid, {recursive: true}, function(err){
|
);
|
||||||
|
fs.rmdir(
|
||||||
|
"./public/uploads/" + req.files.file.uuid,
|
||||||
|
{ recursive: true },
|
||||||
|
function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
//punchsand
|
//punchsand
|
||||||
}
|
}
|
||||||
})
|
|
||||||
res.redirect('/notacat');
|
|
||||||
}
|
}
|
||||||
})
|
);
|
||||||
|
res.redirect("/notacat");
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// load view engine
|
// load view engine
|
||||||
app.set('views', path.join(__dirname, 'views'));
|
app.set("views", path.join(__dirname, "views"));
|
||||||
app.set('view engine', 'pug');
|
app.set("view engine", "pug");
|
||||||
|
|
||||||
|
|
||||||
//set public folder
|
//set public folder
|
||||||
app.use(express.static(path.join(__dirname, 'public')));
|
app.use(express.static(path.join(__dirname, "public")));
|
||||||
|
|
||||||
|
app.get("/", function(req, res) {
|
||||||
|
res.render("index");
|
||||||
app.get('/', function(req, res){
|
|
||||||
res.render('index')
|
|
||||||
});
|
});
|
||||||
app.get('/cats', function(req, res){
|
app.get("/cats", function(req, res) {
|
||||||
|
const catsfolder = "./public/uploads/cats/";
|
||||||
|
|
||||||
const catsfolder = './public/uploads/cats/';
|
res.render("cats", {
|
||||||
|
images: fs.readdirSync(catsfolder.toString())
|
||||||
|
});
|
||||||
res.render('cats', {
|
});
|
||||||
images: fs.readdirSync(catsfolder.toString()),
|
app.get("/bin", function(req, res) {
|
||||||
})
|
const catsfolder = "./public/uploads/bin/";
|
||||||
})
|
|
||||||
app.get('/bin', function(req, res){
|
res.render("bin", {
|
||||||
|
images: fs.readdirSync(catsfolder.toString())
|
||||||
const catsfolder = './public/uploads/bin/';
|
});
|
||||||
|
});
|
||||||
|
|
||||||
res.render('bin', {
|
app.get("/minebitch", function(req, res) {
|
||||||
images: fs.readdirSync(catsfolder.toString()),
|
res.render("minebitch");
|
||||||
})
|
});
|
||||||
})
|
app.get("/notacat", function(req, res) {
|
||||||
|
res.render("notacat");
|
||||||
|
});
|
||||||
|
|
||||||
app.get('/minebitch', function(req, res){
|
app.listen(3000, "0.0.0.0", function() {
|
||||||
res.render('minebitch');
|
console.log("Server started on port 3000...");
|
||||||
})
|
|
||||||
app.get('/notacat', function(req, res){
|
|
||||||
res.render('notacat');
|
|
||||||
})
|
|
||||||
|
|
||||||
app.listen(3000, '0.0.0.0', function(){
|
|
||||||
console.log('Server started on port 3000...');
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
1236
package-lock.json
generated
|
|
@ -5,10 +5,8 @@
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tensorflow-models/mobilenet": "^2.1.0",
|
"@tensorflow-models/mobilenet": "^2.1.0",
|
||||||
"@tensorflow/tfjs": "^2.8.6",
|
|
||||||
"@tensorflow/tfjs-backend-wasm": "^2.7.0",
|
|
||||||
"@tensorflow/tfjs-core": "^3.12.0",
|
"@tensorflow/tfjs-core": "^3.12.0",
|
||||||
"@tensorflow/tfjs-node": "^2.7.0",
|
"@tensorflow/tfjs-node": "^3.12.0",
|
||||||
"concat-stream": "^2.0.0",
|
"concat-stream": "^2.0.0",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
|
|
||||||
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 8.3 KiB |
BIN
public/uploads/cats/1641206391356.jpeg
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 8.3 KiB |