app.py 파일
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
from flask import Flask, render_template
import plotly.figure_factory as ff
import plotly
import json
import numpy as np
import pandas as pd
app = Flask(__name__)
# @는 밑에 def를 바로 실행시킴
@app.route('/')
def index():
#그래프를 받아서 index.html에 띄우기
bar = create_gantt()
def create_gantt():
#엑셀 데이터 read
process_product = pd.read_excel(
#간트차트 생성
fig = ff.create_gantt(
process_product, index_col='Resource',
title='Process by products', group_tasks=True,
show_colorbar=True, bar_width=0.2, showgrid_x=True, showgrid_y=True)
#그래프 json으로 넘겨주기
return graphJSON
#단독으로 파이썬 명령이 들어왔을때만 포트 실행
if __name__ == '__main__':
app.run(debug=True)
#개발할 때 항상 debug mode를 ON으로 하기!
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<!DOCTYPE html>
<html>
<head>
<title>Flask Template Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
media="screen">
<style type="text/css">
.container {
max-width: 500px;
padding-top: 100px;
}
</style>
</head>
<body>
<div class="chart" id="bargraph">
<script>
var graphs = {{plot | safe}};
Plotly.plot('bargraph',graphs,{});
</script>
</div>
<p>create by EUN on 2020.03.05</p>
</body>
</html>
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
Reference Sites
https://blog.heptanalytics.com/flask-plotly-dashboard/
https://community.plot.ly/t/plotly-doesnt-load-most-of-the-time/32095/12
+++추후 프로젝트 방향
https://ssoonidev.tistory.com/71
https://kkamikoon.tistory.com/162
'Flask' 카테고리의 다른 글
[flask-mysql] 설치오류 (0) | 2020.05.12 |
---|