diff --git a/backend/Py.Dockerfile b/backend/Py.Dockerfile index e1b44c4..977e524 100644 --- a/backend/Py.Dockerfile +++ b/backend/Py.Dockerfile @@ -1,37 +1,13 @@ -FROM continuumio/miniconda3 as build +FROM python:3.9 as runtime WORKDIR /app/ -COPY ./python/ /app/src/ +COPY ./python/ /app/ -RUN conda env create -f ./src/environment.yml +RUN python -m pip install gunicorn httpx flask -#RUN echo "conda activate cryptos" >> ~/.bashrc -#SHELL ["/bin/bash", "--login", "-c"] +EXPOSE 5001 -RUN conda install -c conda-forge conda-pack +CMD ["gunicorn", "-b", "0.0.0.0:5001", "crypto.index:app"] -RUN conda pack -n cryptos -o /tmp/env.tar && \ - mkdir /venv/ && cd /venv/ && tar xf /tmp/env.tar && \ - rm /tmp/env.tar - -RUN /venv/bin/conda-unpack - - -FROM python:buster as runtime - -WORKDIR /app/ - -COPY ./python/ /app/src/ -COPY ./automation/bin/ /app/bin/ - -COPY --from=build /venv/ /venv/ - -SHELL ["/bin/bash", "-c"] - -RUN pip install pyinstaller - -RUN pyinstaller -F -n coingecko --clean --log-level DEBUG --distpath /app/bin/ /app/src/coingecko.py && \ - pyinstaller -F -n mindicador --clean --log-level DEBUG --distpath /app/bin/ /app/src/miindicador.py - -ENTRYPOINT [ "/bin/bash" ] +#ENTRYPOINT [ "/bin/bash" ] diff --git a/backend/python/__pycache__/coingecko.cpython-39.pyc b/backend/python/__pycache__/coingecko.cpython-39.pyc index 0e76043..3f1e05b 100644 Binary files a/backend/python/__pycache__/coingecko.cpython-39.pyc and b/backend/python/__pycache__/coingecko.cpython-39.pyc differ diff --git a/backend/python/__pycache__/miindicador.cpython-39.pyc b/backend/python/__pycache__/miindicador.cpython-39.pyc index 3a00642..a4ba594 100644 Binary files a/backend/python/__pycache__/miindicador.cpython-39.pyc and b/backend/python/__pycache__/miindicador.cpython-39.pyc differ diff --git a/backend/python/crypto/__pycache__/coingecko.cpython-39.pyc b/backend/python/crypto/__pycache__/coingecko.cpython-39.pyc new file mode 100644 index 0000000..7f4fb9d Binary files /dev/null and b/backend/python/crypto/__pycache__/coingecko.cpython-39.pyc differ diff --git a/backend/python/crypto/__pycache__/index.cpython-39.pyc b/backend/python/crypto/__pycache__/index.cpython-39.pyc new file mode 100644 index 0000000..ed0b321 Binary files /dev/null and b/backend/python/crypto/__pycache__/index.cpython-39.pyc differ diff --git a/backend/python/crypto/__pycache__/miindicador.cpython-39.pyc b/backend/python/crypto/__pycache__/miindicador.cpython-39.pyc new file mode 100644 index 0000000..e37aa5e Binary files /dev/null and b/backend/python/crypto/__pycache__/miindicador.cpython-39.pyc differ diff --git a/backend/python/coingecko.py b/backend/python/crypto/coingecko.py similarity index 100% rename from backend/python/coingecko.py rename to backend/python/crypto/coingecko.py diff --git a/backend/python/crypto/index.py b/backend/python/crypto/index.py new file mode 100644 index 0000000..9ef4359 --- /dev/null +++ b/backend/python/crypto/index.py @@ -0,0 +1,50 @@ +from flask import Flask + +from crypto.coingecko import CoinGecko +from crypto.miindicador import MiIndicador + +app = Flask(__name__) + + +@app.route('/') +def main(): + output = [ + "", + "", + "Welcome", + "", + "" + ] + return "\n".join(output) + + +@app.route('/crypto/historical///') +@app.route('/crypto/historical////') +def historical_crypto(ids, from_, to, currencies='usd'): + cg = CoinGecko() + return cg.historical(id_=ids, from_=from_, to=to, currency=currencies) + + +@app.route('/crypto/') +@app.route('/crypto//') +def crypto(ids, currencies=('usd', 'clp')): + cg = CoinGecko() + return cg.get(ids, currencies) + + +@app.route('/indicador/historical/') +@app.route('/indicador/historical//') +def historical_indicador(ind, since=None): + mi = MiIndicador() + return mi.historical(ind, since) + + +@app.route('/indicador/') +@app.route('/indicador//') +def indicador(ind, fecha=None): + mi = MiIndicador() + return mi.get(ind, fecha) + + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5001, debug=True) diff --git a/backend/python/miindicador.py b/backend/python/crypto/miindicador.py similarity index 100% rename from backend/python/miindicador.py rename to backend/python/crypto/miindicador.py diff --git a/backend/python/environment.yml b/backend/python/environment.yml deleted file mode 100644 index 544e187..0000000 --- a/backend/python/environment.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: cryptos -channels: - - defaults -dependencies: - - httpx=0.17.1 - - pip=21.1.2 - - python=3.9.5 - - setuptools=52.0.0 -# - pip: -# - pyinstaller==4.3 diff --git a/backend/python/requirements.txt b/backend/python/requirements.txt deleted file mode 100644 index 5f4c202..0000000 --- a/backend/python/requirements.txt +++ /dev/null @@ -1,30 +0,0 @@ -# This file may be used to create an environment using: -# $ conda create --name --file -# platform: win-64 -altgraph=0.17=pypi_0 -ca-certificates=2021.5.25=haa95532_1 -certifi=2021.5.30=py39haa95532_0 -future=0.18.2=pypi_0 -h11=0.12.0=pyhd3eb1b0_0 -h2=4.0.0=py39haa95532_3 -hpack=4.0.0=py_0 -httpcore=0.12.3=pyhd3eb1b0_0 -httpx=0.17.1=pyhd3eb1b0_0 -hyperframe=6.0.1=pyhd3eb1b0_0 -idna=2.10=pyhd3eb1b0_0 -openssl=1.1.1k=h2bbff1b_0 -pefile=2021.5.24=pypi_0 -pip=21.1.2=py39haa95532_0 -pyinstaller=4.3=pypi_0 -pyinstaller-hooks-contrib=2021.1=pypi_0 -python=3.9.5=h6244533_3 -pywin32-ctypes=0.2.0=pypi_0 -rfc3986=1.4.0=py_0 -setuptools=52.0.0=py39haa95532_0 -sniffio=1.2.0=py39haa95532_1 -sqlite=3.35.4=h2bbff1b_0 -tzdata=2020f=h52ac0ba_0 -vc=14.2=h21ff451_1 -vs2015_runtime=14.27.29016=h5e58377_2 -wheel=0.36.2=pyhd3eb1b0_0 -wincertstore=0.2=py39h2bbff1b_0