bin/routes/upload.js

16 lines
415 B
JavaScript
Raw Normal View History

2023-03-04 02:31:07 +01:00
const express = require('express');
const router = express.Router();
const handler = require('express-async-handler');
const content = require('../helpers/content');
async function upload(req, res) {
const data = req.body.text;
const id = await content.create(data);
res.redirect(
'/view?id=' + encodeURIComponent(id)
);
}
router.post('/upload', handler(upload));
module.exports = router;