Пример #1
0
def login(request):
    if request.method == 'GET':
        txt = "Enter user name and password to get access to  dashboard"
        template_data = {"mykey": txt}
        result = render(request, 'login.html', template_data)
    elif request.method == 'POST':
        uname = request.POST.get('username', '')
        psword = request.POST.get('password', '')
        auth_config = Configs(tlusr=uname, tlpwd=psword)
        tlclient = Client(auth_config)
        auth_result = tlclient.get_token()
        auth_result_json = json.dumps(auth_result)
        if auth_result.get('status') != 'success':
            txt = auth_result.get('message')
            template_data = {"mykey": txt}
            result = render(request, 'login.html', template_data)
        else:
            result = HttpResponse(auth_result_json)

    return result
#                                'app1',
#                                '__init__.py')):
apppath = (os.path.join(possible_topdir, 'clientpaperhouse',
                        'clientpaperhouse'))
#    sys.path.insert(0, apppath)

sys.path.insert(0, apppath)

#print(sys.path)

from tokenleaderclient.configs.config_handler import Configs
from tokenleaderclient.client.client import Client
from micros2client.client import MSClient

auth_config = Configs()
tlclient = Client(auth_config)
c = MSClient(tlclient)

parser = argparse.ArgumentParser(add_help=False)

subparser = parser.add_subparsers()

ep3_parser = subparser.add_parser(
    'ep3', help="call the ep3 api route from microservice micros1")

upload_parser = subparser.add_parser('uploadxl',
                                     help='upload invoices from excel file')

upload_parser.add_argument(
    '-f',
    '--file',