Beispiel #1
0
def index():
    data = SourceData()
    with open('./static/hackathon.html', 'w') as f:
        f.write(render_template('index.html', form=data, title=data.title))
    return render_template('index.html', form=data, title=data.title)
Beispiel #2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from flask import Flask, render_template
from data import SourceData

# __name__是系统变量,该变量指的是本py文件的文件名
app = Flask(__name__)
source = SourceData()

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/line')
def line():
    data = source.line
    xAxis = data.pop('legend')
    return render_template('line.html', title='折线图示例', data=data, legend=list(data.keys()), xAxis=xAxis)

@app.route('/bar')
def bar():
    data = source.bar
    xAxis = data.pop('legend')
    return render_template('bar.html', title='柱形图示例', data=data, legend=list(data.keys()), xAxis=xAxis)

@app.route('/pie')
def pie():
    data = source.pie
    return render_template('pie.html', title='饼图示例', data=data, legend=[i.get('name') for i in data])
Beispiel #3
0
def index():
    data = SourceData()
    return render_template('index.html', form=data, title=data.title)
Beispiel #4
0
def dataVisualization():
    data = SourceData()
    return render_template("dataVisualization.html", form=data, title=data.title)
Beispiel #5
0
from data import SourceData

from flask import Flask, render_template

import time

app = Flask(__name__)

data = SourceData()
data.dump_json()
print("The data has been loaded at: " + time.asctime(time.localtime(time.time())))

if __name__ == "__main__":
    with app.app_context():
        rendered = render_template('index.html', form=data, title=data.title)
    with open('./static/hackathon.html', 'w', encoding='utf-8') as f:
        f.write(rendered)
Beispiel #6
0
def index():
    # 新建一个实例
    data = SourceData()
    # 传入一个实例,和实例的标题
    return render_template('index.html', form=data, title=data.title)