diff --git a/server.js b/server.js index 54d46b7..fd55bff 100644 --- a/server.js +++ b/server.js @@ -68,6 +68,7 @@ const TextToSVG = require('text-to-svg') const fs = require('fs') const textToSVG = TextToSVG.loadSync('./static/Dubai-Bold.otf') const app = express() +const path = require('path') const lineLengthviewer = (oneLineText, fontSize) => { //to view the length of each line by pixel let {width} = textToSVG.getMetrics(oneLineText, options = {fontSize: fontSize}) @@ -79,9 +80,9 @@ app.use(express.json()) app.post('/textToSVG', (req, res) => { console.log(req); console.log(req.body); - const text = req.body.text - const screenSize = req.body.screenSize - const userFontSize = req.body.fontSize + let text = req.body.text + let screenSize = req.body.screenSize + let userFontSize = req.body.fontSize let svgFormat = ' ' //header of a svg xml @@ -137,6 +138,11 @@ app.post('/textToSVG', (req, res) => { res.status(201).sendFile('./static/mySVG.svg') }) +app.get('/getSVG', (req, res) => { + const filePath = path.join(__dirname, '/static/mySVG.svg') + console.log(filePath) + res.status(200).sendFile(filePath) +}) const port = process.env.PORT || 3000 app.listen(port, () => { diff --git a/static/mySVG.svg b/static/mySVG.svg index 8ed89c7..f1db5e9 100644 --- a/static/mySVG.svg +++ b/static/mySVG.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file