This is the boilerplate for the File Metadata Microservice project. Instructions for building your project can be found at https://www.freecodecamp.org/learn/apis-and-microservices/apis-and-microservices-projects/file-metadata-microservice
Created
June 21, 2022 19:27
-
-
Save blangue/d6805f5fe32dd44d5af8211989718ddb 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
var express = require('express'); | |
var cors = require('cors'); | |
var multer = require('multer'); | |
const upload = multer(); | |
require('dotenv').config() | |
var app = express(); | |
app.use(cors()); | |
app.use('/public', express.static(process.cwd() + '/public')); | |
app.get('/', function (req, res) { | |
res.sendFile(process.cwd() + '/views/index.html'); | |
}); | |
app.post("/api/fileanalyse", upload.single('upfile'), (req,res)=>{ | |
res.json({name: req.file.originalname, type: req.file.mimetype, size: req.file.size}) | |
}); | |
const port = process.env.PORT || 3000; | |
app.listen(port, function () { | |
console.log('Your app is listening on port ' + port) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment