new GET route

master
mobinkazemi 4 years ago
parent 4e79d85fd4
commit 99048d0322
  1. 12
      server.js
  2. 2
      static/mySVG.svg

@ -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 = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="" > ' //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, () => {

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 239 KiB

Loading…
Cancel
Save