示例#1
0
文件: web.py 项目: melmothx/jsonbot
def login(response, input={}):
    """ display start html so that bot output can follow. """
    try: host = socket.gethostname()
    except AttributeError:
         if os.environ.get('HTTP_HOST'): host = os.environ['HTTP_HOST']
         else: host = os.environ['SERVER_NAME']
    template = LazyDict({'version': getversion(), 'host': host, 'color': Config().color or "#C54848"})
    if input: template.update(input)
    temp = os.path.join(os.getcwd(), 'templates/login.html')
    outstr = template.render(temp)
    response.out.write(outstr)
示例#2
0
文件: web.py 项目: code2u/jsb
def login(response, input={}):
    """ display start html so that bot output can follow. """
    try: host = socket.gethostname()
    except AttributeError:
         if os.environ.get('HTTP_HOST'): host = os.environ['HTTP_HOST']
         else: host = os.environ['SERVER_NAME']
    if 'localhost' in host:  url = 'http://%s/dispatch' % host
    else: url = 'https://%s/dispatch' % host
    template = LazyDict({'url': url, 'version': getversion(), 'host': host, 'color': getmainconfig().color or "#4b7cc6"})
    if input: template.update(input)
    temp = os.path.join(os.getcwd(), 'templates/login.html')
    outstr = template.render(temp)
    response.out.write(outstr)
示例#3
0
文件: web.py 项目: melmothx/jsonbot
def login(response, input={}):
    """ display start html so that bot output can follow. """
    try:
        host = socket.gethostname()
    except AttributeError:
        if os.environ.get('HTTP_HOST'): host = os.environ['HTTP_HOST']
        else: host = os.environ['SERVER_NAME']
    template = LazyDict({
        'version': getversion(),
        'host': host,
        'color': Config().color or "#C54848"
    })
    if input: template.update(input)
    temp = os.path.join(os.getcwd(), 'templates/login.html')
    outstr = template.render(temp)
    response.out.write(outstr)
示例#4
0
 def get(self):
     try:
         cont = self.request.get('continue')
         logging.info('openid - login form %s' % cont)
         urlstring = self.create_openid_url(cont)
         template_values = LazyDict({
             'cont': cont,
             'urlstring': urlstring,
             'appname': getversion()
         })
         try: host = socket.gethostname()
         except AttributeError:
             if os.environ.get('HTTP_HOST'): host = os.environ['HTTP_HOST']
             else: host = os.environ['SERVER_NAME']
         inputdict = {'version': getversion(), 'host': host, 'loginurl': urlstring}
         template_values.update(inputdict)
         temp = os.path.join(os.getcwd(), 'templates/login.html')
         outstr = template_values.render(temp)  
         self.response.out.write(outstr)
     except Exception, ex:
         handle_exception()
示例#5
0
 def get(self):
     try:
         cont = self.request.get('continue')
         logging.info('openid - login form %s' % cont)
         urlstring = self.create_openid_url(cont)
         template_values = LazyDict({
             'continue': cont,
             'urlstring': urlstring,
             'appname': getversion()
         })
         try:
             host = socket.gethostname()
         except AttributeError:
             if os.environ.get('HTTP_HOST'): host = os.environ['HTTP_HOST']
             else: host = os.environ['SERVER_NAME']
         inputdict = {'version': getversion(), 'host': host}
         template_values.update(inputdict)
         temp = os.path.join(os.getcwd(), 'templates/login.html')
         outstr = template_values.render(temp)
         self.response.out.write(outstr)
     except Exception, ex:
         handle_exception()