Initial commit

master
Ian Mancini 5 years ago
commit 0f0e4219e0

@ -0,0 +1,20 @@
module.exports = {
env: {
commonjs: true,
es6: true,
node: true,
},
extends: [
'airbnb-base',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
},
rules: {
"no-console": "off",
},
};

1
.gitattributes vendored

@ -0,0 +1 @@
package-lock.json binary

205
.gitignore vendored

@ -0,0 +1,205 @@
# Created by https://www.gitignore.io/api/vim,node,linux,macos,windows
# Edit at https://www.gitignore.io/?templates=vim,node,linux,macos,windows
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# rollup.js default build output
dist/
# Uncomment the public line if your project uses Gatsby
# https://nextjs.org/blog/next-9-1#public-directory-support
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
# public
# Storybook build outputs
.out
.storybook-out
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# Temporary folders
tmp/
temp/
### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
# Coc configuration directory
.vim
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/vim,node,linux,macos,windows
uploads

@ -0,0 +1,71 @@
const express = require('express');
const fileUpload = require('express-fileupload');
const cors = require('cors');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const { spawnSync } = require('child_process');
const app = express();
const port = process.env.PORT || 3000;
// TODO: Save and load this variables from a file
const city = 'La Plata';
const school = 'Bachillerato de Bellas Artes';
const age = 17;
app.use(fileUpload({
createParentPath: true,
}));
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(morgan('dev'));
app.post('/upload-photo', async (req, res) => {
try {
if (!req.files && !req.files.photo) {
res.send({
status: false,
message: 'No file uploaded',
});
} else {
const { photo } = req.files;
const data = {
name: photo.name,
mimetype: photo.mimetype,
size: photo.size,
};
// move photo to uploads directory
const filepath = `./uploads/${photo.name}`;
photo.mv(filepath);
const python = spawnSync('python3',
['./main.py', `${filepath}`, `${city}`, `${school}`, `${age}`]);
if (python.status === 0) {
res.send({
status: true,
message: 'Photo uploaded and processed succesfully',
data,
});
} else {
res.status(500).send();
}
}
} catch (err) {
res.status(500).send(err);
throw err;
}
});
// TODO: Remove this line. Only use for testing purposes
app.use(express.static('uploads'));
app.listen(port, () => {
console.log(`App is listening on port ${port}.`);
});

@ -0,0 +1,18 @@
import os, sys, random
import argparse
parser = argparse.ArgumentParser(description='Process an image uploaded to the server.')
parser.add_argument('filename', action='store',
help='Filename of photo to process')
parser.add_argument('city', action='store',
help='City of the visitor')
parser.add_argument('school', action='store',
help='School of the visitor')
parser.add_argument('age', action='store',
help='Age of the visitor')
args = parser.parse_args()
print(args.filename)
sys.exit(0);

1996
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,25 @@
{
"name": "spy-camera-server",
"version": "1.0.0",
"description": "Spy camera web server and API",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint index.js",
"fix": "eslint --fix index.js"
},
"author": "Ian Mancini",
"license": "GPL-3.0",
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-fileupload": "^1.1.6",
"morgan": "^1.9.1"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.20.1"
}
}
Loading…
Cancel
Save