UNPKG

convert-svg-react

Version:

Converts SVG XML code to be used as ReactJS component.

41 lines (34 loc) 823 B
"use strict"; // @ts-nocheck var http = require('http'); /** * For use with NodeJS only * Displays new converted svg to a usable svg react components. * @param {string|object} svg */ var openFile = function openFile(svg) { var text = { "Content-Type": "text/plain; charset=utf-8" }; var html = { "Content-Type": "text/html" }; var error = svg.error; var content_type; var content; if (error) { content_type = html; content = svg.error; } else { content_type = text; content = svg; } var requestListener = function requestListener(req, res) { res.writeHead(200, content_type); res.end(content); }; var server = http.createServer(requestListener); server.listen(8002); console.log('Open browswer http://localhost:8002/'); }; module.exports = openFile;