# coding: utf-8 import json import os import codecs import cherrypy from app import database # Method-Dispatching! # (beachte: / relativ zu /login, siehe Konfiguration Server!) #---------------------------------------------------------- class Login_cl(object): #---------------------------------------------------------- exposed = True # gilt für alle Methoden #------------------------------------------------------- def __init__(self): #------------------------------------------------------- self.db_o = database.Database_cl() #**********************REST ANSATZ********************** #------------------------------------------------------- def GET(self, **data_o): #------------------------------------------------------- authenticated = False users = self.db_o.getUsers_px(); if data_o['username'] in users and data_o['password'] == users[data_o['username']]: authenticated = True return json.dumps(authenticated) #------------------------------------------------------- def PUT(self, **data_o): #------------------------------------------------------- success = False users = self.db_o.getUsers_px(); if data_o['username'] not in users: users[data_o['username']] = data_o['password'] self.db_o.saveUsers_px(users); success = True return json.dumps(success) #******************************************************* # EOF