import segno
# var contains a SVG data URI
var = segno.make('Up Jumped the Devil').svg_data_uri()
Here var
contains the QR code as data URI:
data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns[...]
which can be used to embed the code directly into any HTML img, or even a browser.
Another option:
Write the SVG into a binary buffer instead of a file:
import segno
import io
buff = io.BytesIO()
segno.make('Up Jumped the Devil').save(buff, kind="svg")
# Returns the SVG output
buff.getvalue()
buff
contains the complete SVG document:
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="33" height="33" class="segno"><path[...]</svg>
The output cannot be used directly within a HTML page, but you can omit the XML declaration and SVG namespace:
segno.make('Up Jumped the Devil').save(buff, kind="svg", xmldecl=False, svgns=False)
Result of buff.getvalue()
:
<svg width="33" height="33" class="segno"><path[...]</svg>