|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
import swisseph as swe |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EPHE_PATH = "/app/ephemeris" |
|
|
|
|
|
|
|
|
swe.set_ephe_path(EPHE_PATH) |
|
|
os.environ["SWEPH_PATH"] = EPHE_PATH |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from flatlib.chart import Chart |
|
|
from flatlib.datetime import Datetime |
|
|
from flatlib.geopos import GeoPos |
|
|
from flatlib import const |
|
|
|
|
|
|
|
|
swe.set_ephe_path(EPHE_PATH) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from fastapi import FastAPI, Query |
|
|
|
|
|
from urllib.parse import quote |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def Nut(datos: str) -> str: |
|
|
|
|
|
datos = datos.split(sep='|') |
|
|
|
|
|
|
|
|
if len(datos) != 5: |
|
|
return f"{len(datos)} => {datos[0]} = {datos[-1]} Error: se esperan 5 líneas de datos (fecha, hora, zona horaria, latitud, longitud)" |
|
|
|
|
|
|
|
|
date = Datetime(datos[0], datos[1], datos[2]) |
|
|
pos = GeoPos(datos[3], datos[4]) |
|
|
|
|
|
|
|
|
''' |
|
|
pip uninstall pyswisspeh |
|
|
Found existing installation: pyswisseph 2.8.0.post0 |
|
|
Uninstalling pyswisseph-2.8. |
|
|
pip install pyswisseph==2 |
|
|
Pero Pyswisseph == 2.00.00-2 no se puede instalar en sistemas win10. Este error aparecerá: |
|
|
Solo se puede instalar pyswisseph-2.8.0 en |
|
|
Finalmente descubrí cómo hacer que el módulo funcione en Windows. |
|
|
tenemos que usar un archivo de rueda binario de Windows no oficial de |
|
|
' https://www.lfd.uci.edu/~gohlke/pythonlibs/ '. |
|
|
hay diferentes ruedas para diferentes versiones de Python y actualizaciones |
|
|
del módulo. Usé: pyswisseph ‑ 2.5.1.post0 ‑ cp37 ‑ cp37m ‑ win_amd64.whl. |
|
|
use la rueda que se adapte a su versión de python / windows |
|
|
Solución: todo lo que tiene que hacer es abrir la ventana de comandos, escribir |
|
|
'pip install pyswisseph ‑ 2.5.1.post0 ‑ cp37 ‑ cp37m ‑ win_amd64.whl' y se instala. |
|
|
''' |
|
|
|
|
|
|
|
|
|
|
|
chart = Chart(date, pos, hsys=const.HOUSES_EQUAL) |
|
|
|
|
|
chart = Chart(date, pos, IDs=const.LIST_OBJECTS) |
|
|
|
|
|
|
|
|
house1 = chart.get(const.HOUSE1) |
|
|
house2 = chart.get(const.HOUSE2) |
|
|
house3 = chart.get(const.HOUSE3) |
|
|
house4 = chart.get(const.HOUSE4) |
|
|
house5 = chart.get(const.HOUSE5) |
|
|
house6 = chart.get(const.HOUSE6) |
|
|
house10 = chart.get(const.HOUSE10) |
|
|
|
|
|
|
|
|
Sun = chart.get(const.SUN) |
|
|
Moon = chart.get(const.MOON) |
|
|
Mercury = chart.get(const.MERCURY) |
|
|
Venus = chart.get(const.VENUS) |
|
|
Mars = chart.get(const.MARS) |
|
|
Jupiter = chart.get(const.JUPITER) |
|
|
Saturn = chart.get(const.SATURN) |
|
|
Uranus = chart.get(const.URANUS) |
|
|
Neptune = chart.get(const.NEPTUNE) |
|
|
Pluto = chart.get(const.PLUTO) |
|
|
North_Node = chart.get(const.NORTH_NODE) |
|
|
South_Node = chart.get(const.SOUTH_NODE) |
|
|
Syzygy = chart.get(const.SYZYGY) |
|
|
Pars_Fortuna = chart.get(const.PARS_FORTUNA) |
|
|
|
|
|
''' |
|
|
Algenib = chart.getFixedStar(const.STAR_ALGENIB) |
|
|
Alpheratz = chart.getFixedStar(const.STAR_ALPHERATZ) |
|
|
Algol = chart.getFixedStar(const.STAR_ALGOL) |
|
|
... |
|
|
# Aquí estaban tus comentarios de estrellas fijas |
|
|
''' |
|
|
|
|
|
|
|
|
url = ( |
|
|
"https://horoscopes.astro-seek.com/horoscope-chart1-700__radix_ClanNot.png?" |
|
|
|
|
|
|
|
|
"chiron_seda=1" |
|
|
"&lilith_seda=1" |
|
|
"&chiron_asp=1" |
|
|
"&lilith_asp=1" |
|
|
"&uzel_asp=1" |
|
|
"&true_uzel=on" |
|
|
"&minor_45=on" |
|
|
"&minor_135=on" |
|
|
"&equal=1" |
|
|
|
|
|
|
|
|
f"&dum_1_new={quote(str(house1.lon))}" |
|
|
f"&dum_2={quote(str(house2.lon))}" |
|
|
f"&dum_3={quote(str(house3.lon))}" |
|
|
f"&dum_4={quote(str(house4.lon))}" |
|
|
f"&dum_5={quote(str(house5.lon))}" |
|
|
f"&dum_6={quote(str(house6.lon))}" |
|
|
f"&dum_10_new={quote(str(house10.lon))}" |
|
|
|
|
|
|
|
|
f"&planeta_slunce={quote(str(Sun.lon))}" |
|
|
f"&planeta_luna={quote(str(Moon.lon))}" |
|
|
f"&planeta_merkur={quote(str(Mercury.lon))}" |
|
|
f"&planeta_venuse={quote(str(Venus.lon))}" |
|
|
f"&planeta_mars={quote(str(Mars.lon))}" |
|
|
f"&planeta_jupiter={quote(str(Jupiter.lon))}" |
|
|
f"&planeta_saturn={quote(str(Saturn.lon))}" |
|
|
f"&planeta_uran={quote(str(Uranus.lon))}" |
|
|
f"&planeta_neptun={quote(str(Neptune.lon))}" |
|
|
f"&planeta_pluto={quote(str(Pluto.lon))}" |
|
|
f"&planeta_uzel={quote(str(North_Node.lon))}" |
|
|
f"&planeta_fortune={quote(str(Pars_Fortuna.lon))}" |
|
|
f"&planeta_syzygy={quote(str(Syzygy.lon))}" |
|
|
|
|
|
|
|
|
"&r_saturn=ANO" |
|
|
"&r_pluto=ANO" |
|
|
"&r_uzel=ANO" |
|
|
|
|
|
|
|
|
"&tolerance=1" |
|
|
"&tolerance_paral=1.2" |
|
|
"&house_system=equal" |
|
|
"&terms=#tabs_redraw" |
|
|
) |
|
|
|
|
|
return url |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = FastAPI(title="Nut API FastAPI") |
|
|
|
|
|
|
|
|
@app.get("/") |
|
|
def root(): |
|
|
return {"message": "Nut API FastAPI"} |
|
|
|
|
|
|
|
|
@app.get("/nut") |
|
|
def procesar_cadena( |
|
|
datos: str = Query( |
|
|
"???", |
|
|
description="Ejemplo de entrada:1962/02/04|14:30|-05:00|05n00|75w32" |
|
|
) |
|
|
): |
|
|
url_generada = Nut(datos) |
|
|
return {"input": datos, "output": url_generada} |