0
나는 csv 파일을 읽고 웹 페이지에 Javascript DataTables
을 사용하여 표시하는 index.html을 가지고 있습니다. 다음과 같습니다 :javascript/html에서 웹 페이지를로드하기 전에 python 스크립트를 실행하십시오.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>CSV to HTML Table</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/dataTables.bootstrap.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script type="text/javascript" src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script type="text/javascript" src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container-fluid">
<h2>CSV to HTML Table</h2>
<div id='table-container'></div>
</div><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.csv.min.js"></script>
<script type="text/javascript" src="js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="js/dataTables.bootstrap.js"></script>
<script type="text/javascript" src="js/csv_to_html_table.js"></script>
<script type="text/javascript">
function format_link(link){
if (link)
return "<a href='" + link + "' target='_blank'>" + link + "</a>";
else
return "";
}
CsvToHtmlTable.init({
csv_path: 'data/fatty_acid_profiles.csv',
element: 'table-container',
allow_download: true,
csv_options: {separator: ','},
datatables_options: {"paging": false},
custom_formatting: [[4, format_link]]
});
</script>
</body>
</html>
나는 이걸 ec2
인스턴스에서 실행하고 있습니다. 이 URL을 열 때 페이지를로드하기 전에 위의 data/fatty_acid_profiles.csv
파일을 만들고 페이지를로드해야하는 computation.py
이라는 파이썬 스크립트를 실행해야합니다. 페이지를로드하기 전에 파이썬 스크립트를 실행하려면 어떻게해야합니까?
어떻게 HTML을 제공하고 있습니까? – user3080953
실제로 서버를 설정하고 플라스크와 같은 프레임 작업을 사용하지 않으면 어떻게 할 것인지 모르겠다. 링크를 클릭 할 때 호출되는 computed.py 내부의 핸들러를 만든다. http://flask.pocoo.org/docs/0.12/ –
@ user3080953 필자는 AWS ec2에서 Apache Web Server를 실행하고 있다고 썼다. – Xavier