(Nov-12-2017, 11:11 AM)snippsat Wrote:Quote:but it just created a new html page, that also didn't really work cause I can't open it in flask server.The option here is to use Jupyter Notebook,
What I wanted to do is to show the csv table in index.html template
Notebooks can be shared for free without using a server examples here.
Quote:how to send the "dataset.html" content to "index.html"??Jinja is build into Flask,as it's made bye same author.
I don't know how to use jinja, I'm really new to python programming
It's a way for getting stuff from a Flask server and out to client side(browser).
Here is the setup,
now have control over where in page it should be and size/color and more though CSS.
Folder setup:
tab_test\ |-- app.py |-- email.csv templates\ |-- index.html static\ css\ |-- style.cssapp.py:
from flask import Flask, render_template import tablib import os app = Flask (__name__) dataset = tablib.Dataset() with open(os.path.join(os.path.dirname(__file__),'email.csv')) as f: dataset.csv = f.read() @app.route("/") def index(): data = dataset.html #return dataset.html return render_template('index.html', data=data) if __name__ == "__main__": app.run()index.html:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <link rel=stylesheet type=text/css href="{{ url_for('static', filename='css/style.css') }}"/> <title>Show CSV</title> </head> <body> <div class="table"> {% block body %} {{ data|safe }} {% endblock %} </div> </body> </html>style.css:
.table { position: absolute; font-size: 150%; width: 480px; height: 200px; z-index: 15; top: 20%; left: 50%; margin: -100px 0 0 -150px; background: rgb(236, 240, 204); }
hey, it works.
Thank you so much.