Created
June 6, 2021 13:29
-
-
Save hoangsetup/a7373dd8b7e1d8d44cb9bfbb8c161476 to your computer and use it in GitHub Desktop.
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; | |
res.contentType('image/jpeg'); | |
res.send(await glassifyLib.glassify(uploadedImage.data)); | |
} catch(error) { | |
res.status(500).json({ message: error.message }); | |
} | |
}); | |
const PORT = process.env.PORT || 3000; | |
app.listen(PORT, () => { | |
console.log(`Server is listening on: ${PORT}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment