""" Title: D3-Visualiser Licence: GPL-3 Author: Jesper Bergman """ import os; import random; import plotly; import plotly.graph_objs as go; import pandas as pd; import numpy as np; import json; from flask import Flask, flash, redirect, render_template, request, session, abort; import jinja2; app = Flask(__name__); def create_plot(): N = 40 x = np.linspace(0, 1, N) y = np.random.randn(N) df = pd.DataFrame({'x': x, 'y': y}) #creating a sample dataframe plotly.offine.plot({ data=[ go.Bar( x=df['x'],y=df['y'], auto_open=True) ] }); graphJSON = json.dumps(data, cls=plotly.utils.PlotlyJSONEncoder); return graphJSON; @app.route("/") def index(): bar = create_plot(); return render_template('index.html'); @app.route("/hello") def hello(): return "Hello World"; @app.route("/api") def api(): res = 199999+22223199123; return res; if __name__ == "__main__": app.run(host="127.0.0.1", port=9000);