g-battaglia / kerykeion

Data driven Astrology 💫
Kerykeion is a python library for astrology. It can generate SVG charts and extract all data about a birthchart, a synastry chart and a transit chart.
https://kerykeion.net
GNU Affero General Public License v3.0
297 stars 103 forks source link

How to get SVG code of chart? #106

Closed wrld-builder closed 2 months ago

wrld-builder commented 6 months ago

I have this code snippet:

@app.get("/get_svg_code")
def make_svg(name: str, year: int, month: int, day: int, hour: int, minute: int, city: str):
    kanye = AstrologicalSubject(name, year, month, day, hour, minute, city)

    pic = KerykeionChartSVG(kanye, chart_type="Natal")

    return pic.makeTemplate()

but this return wrong code. How can I do it correctly?

wrld-builder commented 6 months ago

I can get code by return pic.template but I can't insert this data into my web page into <svg> tag. how can I do it?

g-battaglia commented 6 months ago

Hi, it look's it's not a problem specific to kerykeion but to the web framework that you are using. The answer depends of the technology, in general terms you can't return a raw SVG from a request, it must be correctly formatted. The format depends of what you need to be inside the response.