Sammlung
This commit is contained in:
1
Sammlung/p1/test1/app/__init__.py
Normal file
1
Sammlung/p1/test1/app/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
# python package initialization
|
BIN
Sammlung/p1/test1/app/__pycache__/__init__.cpython-34.pyc
Normal file
BIN
Sammlung/p1/test1/app/__pycache__/__init__.cpython-34.pyc
Normal file
Binary file not shown.
BIN
Sammlung/p1/test1/app/__pycache__/__init__.cpython-35.pyc
Normal file
BIN
Sammlung/p1/test1/app/__pycache__/__init__.cpython-35.pyc
Normal file
Binary file not shown.
BIN
Sammlung/p1/test1/app/__pycache__/application.cpython-34.pyc
Normal file
BIN
Sammlung/p1/test1/app/__pycache__/application.cpython-34.pyc
Normal file
Binary file not shown.
BIN
Sammlung/p1/test1/app/__pycache__/application.cpython-35.pyc
Normal file
BIN
Sammlung/p1/test1/app/__pycache__/application.cpython-35.pyc
Normal file
Binary file not shown.
82
Sammlung/p1/test1/app/application.py
Normal file
82
Sammlung/p1/test1/app/application.py
Normal file
@ -0,0 +1,82 @@
|
||||
# coding: utf-8
|
||||
import cherrypy
|
||||
import json
|
||||
import codecs
|
||||
#--------------------------------------
|
||||
|
||||
class Application_cl(object):
|
||||
|
||||
|
||||
#---------------------------------------------------
|
||||
def __init__(self):
|
||||
#---------------------------------------------------
|
||||
# constructor
|
||||
pass
|
||||
#---------------------------------------------------
|
||||
|
||||
|
||||
#---------------------------------------------------
|
||||
def module(self):
|
||||
#---------------------------------------------------
|
||||
anfang_s = """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="main.js">
|
||||
</script>
|
||||
<title>
|
||||
Titel
|
||||
</title>
|
||||
<meta charset= "UTF-8"/>
|
||||
</head>
|
||||
<body>"""
|
||||
|
||||
ende_s = """
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
# Inhalt der Datei "module.json" im Verzeichnis "data"
|
||||
# einlesen und als Python-Datenstruktur ablegen
|
||||
# verwenden Sie dazu das Modul "json"
|
||||
json_modul = codecs.open("./data/module.json", "r", "UTF-8")
|
||||
modul_inhalt = json.load(json_modul)
|
||||
json_modul.close()
|
||||
|
||||
##markup_s = modul_inhalt
|
||||
|
||||
|
||||
# anschließend einfaches Markup aufbauen:
|
||||
# einleitenden Teil des Markups zuweisen
|
||||
# Schleife über alle Einträge in der Python-Datenstruktur:
|
||||
# Daten extrahieren und weiteres Markup damit erzeugen und anhängen
|
||||
# abschließenden Teil des Markups anhängen
|
||||
# erzeugtes Markup als Ergebnis zurückliefern
|
||||
markup_s = anfang_s
|
||||
#markup_s += "<ul>"
|
||||
for key_s in sorted(modul_inhalt):
|
||||
markup_s += "<ul> <h3 onclick=\"change_view('" + str(key_s) + "')\"" + ">" + str(key_s) + '</h3>' + '<div style="display:block;" id="' + str(key_s) + '">'
|
||||
for key2_s in sorted(modul_inhalt[key_s]):
|
||||
markup_s += '<li>' + str(modul_inhalt[key_s][key2_s])
|
||||
markup_s += '</ul> </div>'
|
||||
#markup_s += "</ul>"
|
||||
|
||||
markup_s += ende_s
|
||||
|
||||
return markup_s
|
||||
|
||||
module.exposed = True
|
||||
#---------------------------------------------------
|
||||
|
||||
|
||||
#---------------------------------------------------
|
||||
def default(self, *arglist, **kwargs):
|
||||
#---------------------------------------------------
|
||||
msg_s = "unbekannte Anforderung: " + \
|
||||
str (arglist) + \
|
||||
'' +\
|
||||
str (kwargs)
|
||||
raise cherrypy.HTTPError(404, msg_s)
|
||||
|
||||
default.exposed = True
|
||||
#---------------------------------------------------
|
||||
# EOF
|
16
Sammlung/p1/test1/content/index.html
Normal file
16
Sammlung/p1/test1/content/index.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
Titel
|
||||
</title>
|
||||
<meta charset= "UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>
|
||||
<a href="/module">Modul</a>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
14
Sammlung/p1/test1/content/main.js
Normal file
14
Sammlung/p1/test1/content/main.js
Normal file
@ -0,0 +1,14 @@
|
||||
function change_view(idContainer){
|
||||
var element_o = document.getElementById(idContainer);
|
||||
|
||||
|
||||
if (element_o.style.display != "none"){
|
||||
|
||||
element_o.style.display = "none";
|
||||
}
|
||||
else{
|
||||
|
||||
element_o.style.display = "block";
|
||||
}
|
||||
|
||||
}
|
18
Sammlung/p1/test1/content/module.html
Normal file
18
Sammlung/p1/test1/content/module.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
Titel
|
||||
</title>
|
||||
<meta charset= "UTF-8"/>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Inhalt
|
||||
</p>
|
||||
<p>
|
||||
<a href="/module">Modul</a>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
20
Sammlung/p1/test1/data/module.json
Normal file
20
Sammlung/p1/test1/data/module.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"WEB": {
|
||||
"bezeichnung": "Web-Engineering",
|
||||
"studiengang": "Bachelor Informatik",
|
||||
"semester": 3,
|
||||
"beschreibung": "Hier kann man einen Beschreibungstext vorsehen"
|
||||
},
|
||||
"IAS": {
|
||||
"bezeichnung": "Interaktive Systeme",
|
||||
"studiengang": "Bachelor Informatik",
|
||||
"semester": 4,
|
||||
"beschreibung": "Hier kann man einen Beschreibungstext vorsehen"
|
||||
},
|
||||
"SWE": {
|
||||
"bezeichnung": "Software Engineering",
|
||||
"studiengang": "Bachelor Informatik",
|
||||
"semester": 5,
|
||||
"beschreibung": "Hier kann man einen Beschreibungstext vorsehen"
|
||||
}
|
||||
}
|
39
Sammlung/p1/test1/server.py
Normal file
39
Sammlung/p1/test1/server.py
Normal file
@ -0,0 +1,39 @@
|
||||
#coding: utf-8
|
||||
import os
|
||||
import cherrypy
|
||||
from app import application
|
||||
#--------------------------------------
|
||||
def main():
|
||||
#--------------------------------------
|
||||
# Get current directory
|
||||
try:
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
except:
|
||||
current_dir = os.path.dirname(os.path.abspath(sys.executable))
|
||||
# disable autoreload and timeout_monitor
|
||||
cherrypy.engine.autoreload.unsubscribe()
|
||||
cherrypy.engine.timeout_monitor.unsubscribe()
|
||||
# Static content config
|
||||
static_config = {
|
||||
'/' : {
|
||||
'tools.staticdir.root': current_dir,
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir':'./content',
|
||||
'tools.staticdir.index':'index.html'
|
||||
}
|
||||
}
|
||||
# Mount static content handler
|
||||
root_o = cherrypy.tree.mount(application.Application_cl() ,'/', static_config)
|
||||
# suppress traceback-info
|
||||
cherrypy.config.update({'request.show_tracebacks':False})
|
||||
# Start server
|
||||
cherrypy.engine.start()
|
||||
cherrypy.engine.block()
|
||||
|
||||
#--------------------------------------
|
||||
if __name__ == '__main__':
|
||||
#--------------------------------------
|
||||
main()
|
||||
|
||||
|
||||
# EOF
|
Reference in New Issue
Block a user