Added support for custom templates
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
import os
|
||||
import logging
|
||||
from flask import Flask, render_template, Response, send_from_directory, request, current_app
|
||||
|
||||
app = Flask(__name__)
|
||||
logging.basicConfig()
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def main():
|
||||
return render_template('main.html', title='pyDashie')
|
||||
|
||||
@app.route("/dashboard/<dashlayout>/")
|
||||
def custom_layout(dashlayout):
|
||||
return render_template('%s.html'%dashlayout, title='pyDashie')
|
||||
|
||||
@app.route("/assets/application.js")
|
||||
def javascripts():
|
||||
@@ -40,7 +48,7 @@ def javascripts():
|
||||
for path in scripts:
|
||||
output.append('// JS: %s\n' % path)
|
||||
if '.coffee' in path:
|
||||
print('Compiling Coffee for %s ' % path)
|
||||
log.info('Compiling Coffee for %s ' % path)
|
||||
contents = coffeescript.compile_file(path)
|
||||
else:
|
||||
f = open(path)
|
||||
@@ -136,7 +144,7 @@ def purge_streams():
|
||||
def close_stream(*args, **kwargs):
|
||||
event_stream_port = args[2][1]
|
||||
del xyzzy.events_queue[event_stream_port]
|
||||
print('Client %s disconnected. Total Clients: %s' % (event_stream_port, len(xyzzy.events_queue)))
|
||||
log.info('Client %s disconnected. Total Clients: %s' % (event_stream_port, len(xyzzy.events_queue)))
|
||||
|
||||
if __name__ == "__main__":
|
||||
import SocketServer
|
||||
|
||||
41
pydashie/templates/small.html
Normal file
41
pydashie/templates/small.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
||||
<title>{{title}}</title>
|
||||
|
||||
<!-- The javascript and css are managed by sprockets. The files can be found in the /assets folder-->
|
||||
<script type="text/javascript" src="/assets/application.js"></script>
|
||||
<link rel="stylesheet" href="/assets/application.css">
|
||||
|
||||
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700' rel='stylesheet' type='text/css'>
|
||||
<link rel="icon" href="/assets/images/favicon.ico">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div class="gridster">
|
||||
<ul>
|
||||
<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
|
||||
<div data-id="welcome" data-view="Text" data-title="Hello" data-text="This is your shiny new (python powered) dashboard." data-moreinfo="Protip: You can drag the widgets around!"></div>
|
||||
</li>
|
||||
|
||||
<li data-row="1" data-col="3" data-sizex="1" data-sizey="1">
|
||||
<div data-id="synergy" data-view="Meter" data-title="Synergy" data-min="0" data-max="100"></div>
|
||||
</li>
|
||||
|
||||
<li data-row="2" data-col="1" data-sizex="1" data-sizey="1">
|
||||
<div data-id="clock" data-view="Clock" data-title="Clock"></div>
|
||||
</li>
|
||||
|
||||
<li data-row="2" data-col="2" data-sizex="1" data-sizey="1">
|
||||
<div data-view="Image" data-image="/images/dashie.png"></div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user