Sammlung
This commit is contained in:
Binary file not shown.
48
Sammlung/Praktikum/2/ias-p2_a0.02/app/test.py
Normal file
48
Sammlung/Praktikum/2/ias-p2_a0.02/app/test.py
Normal file
@ -0,0 +1,48 @@
|
||||
# coding: utf-8
|
||||
import os
|
||||
import os.path
|
||||
import codecs
|
||||
import json
|
||||
import time
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
class test_cl(object):
|
||||
globalNumber = 0
|
||||
|
||||
|
||||
exposed = True
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
def __init__(self):
|
||||
#----------------------------------------------------------------------------
|
||||
pass
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
def REFRESH(self, value):
|
||||
print("Value receivt: %s" % value)
|
||||
starttime= time.time()
|
||||
#server und client selbe zahl hat wartezustand
|
||||
while (int(value) == int(self.globalNumber)):
|
||||
time.sleep(1)
|
||||
print("Sessiontimer: %d" % (time.time() - starttime))
|
||||
|
||||
if (time.time() - starttime) > 3600:
|
||||
print("Client down")
|
||||
return json.dumps(self.globalNumber)
|
||||
|
||||
print("new Value sent: %d" %self.globalNumber)
|
||||
return json.dumps(self.globalNumber)
|
||||
|
||||
def INC(self):
|
||||
self.globalNumber = self.globalNumber + 1
|
||||
print(self.globalNumber)
|
||||
#-----------------------------------------------------------------------------
|
||||
def default():
|
||||
#-----------------------------------------------------------------------------
|
||||
pass
|
||||
|
||||
|
||||
|
||||
# EOF
|
16
Sammlung/Praktikum/2/ias-p2_a0.02/html/index.html
Normal file
16
Sammlung/Praktikum/2/ias-p2_a0.02/html/index.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Clock Animation</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||
<script type="text/javascript" src="clock.js"></script>
|
||||
<style type="text/css">
|
||||
canvas {
|
||||
background-color: #000;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="initClock('clock', 100, 'rgb(255, 255, 255)')">
|
||||
<canvas id="clock"></canvas>
|
||||
</body>
|
||||
</html>
|
9597
Sammlung/Praktikum/2/ias-p2_a0.02/js/jquery-1.9.1.js
vendored
Normal file
9597
Sammlung/Praktikum/2/ias-p2_a0.02/js/jquery-1.9.1.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
70
Sammlung/Praktikum/2/ias-p2_a0.02/js/test.js
Normal file
70
Sammlung/Praktikum/2/ias-p2_a0.02/js/test.js
Normal file
@ -0,0 +1,70 @@
|
||||
var number = -1;
|
||||
|
||||
var waiting = function(){
|
||||
var path = '/test';
|
||||
path += '/' + number;
|
||||
|
||||
$.ajax({
|
||||
url: path,
|
||||
type: 'REFRESH',
|
||||
dataType: "json"
|
||||
})
|
||||
.done(function(data){
|
||||
$("#idNumberArea").html(data);
|
||||
number = data;
|
||||
waiting();
|
||||
})
|
||||
.fail(function(){
|
||||
//alert("Server lost");
|
||||
//tritt bei Reload der Seite einmal auf, danach alles OK
|
||||
//Wayne, deswegen auskommentiert
|
||||
});
|
||||
};
|
||||
|
||||
inc = function(){
|
||||
$.ajax({
|
||||
url: '/test',
|
||||
type: 'INC'
|
||||
})
|
||||
};
|
||||
|
||||
$(document).ready(function(){
|
||||
waiting();
|
||||
});
|
||||
|
||||
|
||||
var clock_id = 'clock';
|
||||
var clock_size = 100;
|
||||
var clock_color = 'rgb(0, 0, 0)';
|
||||
setInterval(drawClock, 250);
|
||||
|
||||
/**
|
||||
* Initializes the clock canvas.
|
||||
*
|
||||
* @param id
|
||||
* The ID of the clock canvas element
|
||||
* @param size
|
||||
* The size of the clock (size == width == height)
|
||||
* @param color
|
||||
* The color of the clock in 'rgb(r, g, b)' format
|
||||
*/
|
||||
function initClock(id, size, color) {
|
||||
clock_id = id;
|
||||
clock_size = size;
|
||||
clock_color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the clock.
|
||||
*/
|
||||
function drawClock() {
|
||||
var canvas = document.getElementById(clock_id);
|
||||
var ctx = canvas.getContext('2d');
|
||||
canvas.width = clock_size;
|
||||
canvas.height = clock_size;
|
||||
|
||||
ctx.translate(clock_size / 2, clock_size / 2);
|
||||
ctx.fillStyle = clock_color;
|
||||
|
||||
ctx.save();
|
||||
for ( var i = 1; i <p>
|
19
Sammlung/Praktikum/2/ias-p2_a0.02/server.conf
Normal file
19
Sammlung/Praktikum/2/ias-p2_a0.02/server.conf
Normal file
@ -0,0 +1,19 @@
|
||||
[global]
|
||||
tools.log_headers.on: True
|
||||
tools.sessions.on: False
|
||||
tools.encode.on: True
|
||||
tools.encode.encoding:"utf-8"
|
||||
|
||||
server.socket_port: 8080
|
||||
server.socket_timeout:60
|
||||
|
||||
server.thread_pool: 10
|
||||
server.environment: "production"
|
||||
log.screen: True
|
||||
|
||||
[/]
|
||||
tools.staticdir.root: cherrypy.Application.currentDir_s
|
||||
tools.staticdir.on = True
|
||||
tools.staticdir.dir = '.'
|
||||
tools.staticdir.index = 'html/index.html'
|
||||
|
45
Sammlung/Praktikum/2/ias-p2_a0.02/server.py
Normal file
45
Sammlung/Praktikum/2/ias-p2_a0.02/server.py
Normal file
@ -0,0 +1,45 @@
|
||||
# coding:utf-8
|
||||
|
||||
import os.path
|
||||
import cherrypy
|
||||
|
||||
from app import test
|
||||
#----------------------------------------------------------
|
||||
def main():
|
||||
#----------------------------------------------------------
|
||||
|
||||
# aktuelles Verzeichnis ermitteln, damit es in der Konfigurationsdatei als
|
||||
# Bezugspunkt verwendet werden kann
|
||||
try: # aktuelles Verzeichnis als absoluter Pfad
|
||||
currentDir_s = os.path.dirname(os.path.abspath(__file__))
|
||||
except:
|
||||
currentDir_s = os.path.dirname(os.path.abspath(sys.executable))
|
||||
cherrypy.Application.currentDir_s = currentDir_s
|
||||
|
||||
configFileName_s = 'server.conf' # im aktuellen Verzeichnis
|
||||
if os.path.exists(configFileName_s) == False:
|
||||
# Datei gibt es nicht
|
||||
configFileName_s = None
|
||||
print("doof")
|
||||
print("cool")
|
||||
# autoreload und timeout_Monitor hier abschalten
|
||||
# für cherrypy-Versionen >= "3.1.0" !
|
||||
cherrypy.engine.autoreload.unsubscribe()
|
||||
cherrypy.engine.timeout_monitor.unsubscribe()
|
||||
|
||||
|
||||
cherrypy.tree.mount(
|
||||
None, '/', configFileName_s
|
||||
)
|
||||
|
||||
cherrypy.tree.mount(
|
||||
test.test_cl(), '/test', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}}
|
||||
)
|
||||
|
||||
cherrypy.engine.start()
|
||||
cherrypy.engine.block()
|
||||
|
||||
#----------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
#----------------------------------------------------------
|
||||
main()
|
Reference in New Issue
Block a user