PPM2: select
This commit is contained in:
33
Praktikum2/ppm2/app/category.py
Normal file
33
Praktikum2/ppm2/app/category.py
Normal file
@ -0,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
|
||||
import json
|
||||
import cherrypy
|
||||
from app import database
|
||||
|
||||
#-------------------------------------------------------
|
||||
class Category(object):
|
||||
#-------------------------------------------------------
|
||||
|
||||
exposed = True # gilt für alle Methoden
|
||||
|
||||
#-------------------------------------------------------
|
||||
def __init__(self):
|
||||
#-------------------------------------------------------
|
||||
self.db = database.Database()
|
||||
|
||||
#-------------------------------------------------------
|
||||
def GET(self, cat=None):
|
||||
#-------------------------------------------------------
|
||||
data = {}
|
||||
if(cat != None):
|
||||
self.db.ReadAll()
|
||||
data['content'] = {}
|
||||
data['headings'] = {}
|
||||
data['category'] = cat
|
||||
data['content'] = self.db.data[cat]
|
||||
if(len(data['content']) != 0):
|
||||
print(len(data['content']))
|
||||
contentFirst = list(data['content'].keys())[0]
|
||||
data['headings'] = list(data['content'][contentFirst].keys())
|
||||
print(data)
|
||||
return json.dumps(data)
|
Reference in New Issue
Block a user