This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from 'express'; | |
import fileUpload, { UploadedFile } from 'express-fileupload'; | |
import glassifyLib from './glassifyLib'; | |
const app = express(); | |
app.use(fileUpload()); | |
app.post('/glassify', async (req, res) => { | |
try { | |
const uploadedImage = req.files?.image as UploadedFile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '@tensorflow/tfjs-node'; | |
import * as canvas from 'canvas'; | |
import * as faceapi from 'face-api.js'; | |
import path from 'path'; | |
import Jimp from 'jimp'; | |
const { Canvas, Image, ImageData } = canvas; | |
faceapi.env.monkeyPatch({ Canvas: Canvas as any, Image: Image as any, ImageData }); | |
class GlassifyLib { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as fs from 'fs'; | |
import * as path from 'path'; | |
import GlassifyLib from './glassifyLib'; | |
(async () => { | |
const imageBuffer = fs.readFileSync(path.join(__dirname, '../', 'public/images/demo.jpg')); | |
const output = await GlassifyLib.glassify(imageBuffer); | |
await fs.writeFileSync( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '@tensorflow/tfjs-node'; | |
import * as canvas from 'canvas'; | |
import * as faceapi from 'face-api.js'; | |
import path from 'path'; | |
const { Canvas, Image, ImageData } = canvas; | |
faceapi.env.monkeyPatch({ Canvas: Canvas as any, Image: Image as any, ImageData }); | |
class GlassifyLib { | |
async glassify(imageBuffer: Buffer): Promise<Buffer> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/public/js/main.js b/public/js/main.js | |
index 1274c8a..a2e19e7 100644 | |
--- a/public/js/main.js | |
+++ b/public/js/main.js | |
@@ -1,5 +1,7 @@ | |
(function ($, window, document) { | |
$(async function () { | |
+ const socket = io(); | |
+ | |
function getStatusBadge(status) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/public/index.html b/public/index.html | |
index f1b93cc..9eed948 100644 | |
--- a/public/index.html | |
+++ b/public/index.html | |
@@ -6,9 +6,11 @@ | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" | |
integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous"> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css"> | |
+ <link rel="stylesheet" href="css/stype.css"> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/app.ts b/src/app.ts | |
index 60fe0f7..3d64562 100644 | |
--- a/src/app.ts | |
+++ b/src/app.ts | |
@@ -1,5 +1,6 @@ | |
import express from 'express'; | |
import pm2Lib from './pm2Lib'; | |
+import socketIO from './socketIO'; | |
const app = express(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Server as HttpServer } from "http"; | |
import { Server } from "socket.io"; | |
import pm2Lib, { IProcessOutLog } from "./pm2Lib"; | |
class SocketIO { | |
private io: Server | undefined; | |
init(httpServer: HttpServer) { | |
if (this.io !== undefined) { | |
throw new Error('Socket server already defined!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/pm2Lib.ts b/src/pm2Lib.ts | |
index 4b8cd2f..33e315a 100644 | |
--- a/src/pm2Lib.ts | |
+++ b/src/pm2Lib.ts | |
@@ -1,10 +1,24 @@ | |
import pm2, { Proc, ProcessDescription, StartOptions } from 'pm2'; | |
import { promisify } from 'util'; | |
+import { EventEmitter } from 'events'; | |
+ | |
+export interface IProcessOutLog { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($, window, document) { | |
$(async function () { | |
function getStatusBadge(status) { | |
switch (status) { | |
case "stopped": | |
return `<span class="badge badge-danger">${status}</span>`; | |
case "online": | |
return `<span class="badge badge-success">${status}</span>`; | |
default: | |
return `<span class="badge badge-default">${status}</span>`; |