Commit 48f10ddb authored by Nicolas Herbaut's avatar Nicolas Herbaut
Browse files

tamed jinja2 template through flask

parent e9c44f5c
from python:3.6-slim from python:3.6-slim
RUN apt-get update && apt-get install tk-dev --yes --no-install-recommends && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install tk-dev --yes --no-install-recommends && rm -rf /var/lib/apt/lists/*
COPY requirements-python3.txt /tmp/requirements-python3.txt COPY ./dist/*.whl /tmp
RUN pip install -r /tmp/requirements-python3.txt RUN pip install /tmp/*.whl
COPY ./dist/Flow_Matrix_Web_page-0.0.3-py3.6.egg /tmp/Flow_Matrix_Web_page-0.0.3-py3.6.egg
RUN easy_install /tmp/Flow_Matrix_Web_page-0.0.3-py3.6.egg
EXPOSE 5011 EXPOSE 5011
CMD flow-matrix --influxdb_host $INFLUX_DB_HOST CMD flow-matrix --influxdb_host $INFLUX_DB_HOST
...@@ -20,11 +20,11 @@ install: clean ...@@ -20,11 +20,11 @@ install: clean
python setup.py install python setup.py install
build: build:
.venv3/bin/python setup.py bdist_egg .venv/bin/python setup.py bdist_wheel
docker-build: docker-build:
docker build . -t nherbaut/flowmatrix docker build . -t nherbaut/flowmatrix
push: push:
docker push nherbaut/flowmatrix docker push nherbaut/flowmatrix
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from flask import Flask, render_template from flask import Flask
from jinja2 import Environment, PackageLoader
from flowmatrix.flowlib import get_data_full, get_data from flowmatrix.flowlib import get_data_full, get_data
import argparse import argparse
import os import os
...@@ -18,18 +19,18 @@ parser.add_argument('--influxdb_database', type=str, help='database to used in t ...@@ -18,18 +19,18 @@ parser.add_argument('--influxdb_database', type=str, help='database to used in t
args = parser.parse_args() args = parser.parse_args()
e = Environment(loader=PackageLoader("flowmatrix", "../flowmatrix/templates/"))
@app.route("/") @app.route("/")
def data(): def data():
matrix, svg = get_data(args.influxdb_host, args.influxdb_port) matrix, svg = get_data(args.influxdb_host, args.influxdb_port)
return render_template('index.html', data=matrix.to_dict(), svg=svg) return e.get_template("index.html").render(data=matrix.to_dict(), svg=svg)
@app.route("/full") @app.route("/full")
def data_full(): def data_full():
matrix, svg = get_data_full(args.influxdb_host, args.influxdb_port) matrix, svg = get_data_full(args.influxdb_host, args.influxdb_port)
return render_template('index.html', data=matrix.to_dict(), svg=svg) return e.get_template("index.html").render(data=matrix.to_dict(), svg=svg)
app.template_folder = "/usr/local/lib/python3.6/site-packages/Flow_Matrix_Web_page-0.0.3-py3.6.egg/flowmatrix/templates/"
app.run(host="0.0.0.0", port=args.flow_matrix_port) app.run(host="0.0.0.0", port=args.flow_matrix_port)
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
from setuptools import setup from setuptools import setup
from setuptools import find_packages from setuptools import find_packages
with open("requirements.txt") as requirements_file:
install_requires = requirements_file.read().split("\n")
setup( setup(
name='Flow Matrix Web page', name='Flow Matrix Web page',
package=["flowmatrix"], package=["flowmatrix"],
...@@ -13,22 +17,6 @@ setup( ...@@ -13,22 +17,6 @@ setup(
scripts=['bin/flow-matrix'], scripts=['bin/flow-matrix'],
include_package_data=True, include_package_data=True,
zip_safe=False, zip_safe=False,
install_requires=[ install_requires=install_requires,
"chardet==3.0.4",
"click==6.7",
"Flask==0.12.2",
"idna==2.6",
"influxdb==5.0.0",
"itsdangerous==0.24",
"Jinja2==2.10",
"MarkupSafe==1.0",
"numpy",
"pandas==0.21.0",
"python-dateutil==2.6.1",
"pytz==2017.3",
"requests==2.18.4",
"six==1.11.0",
"urllib3==1.22",
"Werkzeug==0.12.2"],
packages=find_packages() packages=find_packages()
) )
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment