37 lines
985 B
Python
37 lines
985 B
Python
|
# coding: utf-8
|
||
|
|
||
|
import json
|
||
|
import os
|
||
|
import codecs
|
||
|
import cherrypy
|
||
|
|
||
|
#----------------------------------------------------------
|
||
|
class Templates(object):
|
||
|
#----------------------------------------------------------
|
||
|
|
||
|
exposed = True # gilt für alle Methoden
|
||
|
|
||
|
#-------------------------------------------------------
|
||
|
def __init__(self):
|
||
|
#-------------------------------------------------------
|
||
|
pass
|
||
|
|
||
|
#-------------------------------------------------------
|
||
|
def GET(self):
|
||
|
#-------------------------------------------------------
|
||
|
retVal = {
|
||
|
'templates': {}
|
||
|
}
|
||
|
|
||
|
files = os.listdir('templates')
|
||
|
for fileName in files:
|
||
|
if fileName != '.DS_Store':
|
||
|
file = codecs.open(os.path.join('templates', fileName), 'rU', 'utf-8', errors='ignore')
|
||
|
content = file.read()
|
||
|
file.close()
|
||
|
retVal["templates"][fileName] = content
|
||
|
print(retVal)
|
||
|
|
||
|
return json.dumps(retVal)
|
||
|
|
||
|
# EOF
|