• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python web.cookies函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中web.cookies函数的典型用法代码示例。如果您正苦于以下问题:Python cookies函数的具体用法?Python cookies怎么用?Python cookies使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cookies函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: POST

	def POST(self):
		web.header("Content-Type","text/html; charset=utf-8")
		content = ""
		if check_sid(web.cookies().get('sid')):
			connrtn = conn()
			if (connrtn == None):
				try:
					num = int(web.input().get('val', None))
				except:
					content += "Invalid input, assuming 0\n"
					num = 0
				buf = send_recv(47 * '0')
				if (buf[43] == '1'): #input request
					res = "Input request #" + str(str_to_num(buf[38:42])) + " : " + str(num)
					buf = num_to_str(num) + 10 * '0' + '010'; #set in_ack
					send_recv(buf)
					buf = num_to_str(num) + 10 * '0' + '000'; #clr in_ack
					send_recv(buf)
					io_history = open('interaction.txt', 'a')
					io_history.write(res + "\n")
					io_history.close()
				sock.close()
				raise web.seeother('/interaction')
			else:
				content += connrtn
		else:
			content += "Serving other user.\nACCESS DENIED.\n"
		return render.interaction(get_status(), check_sid(web.cookies().get('sid')), content, False, False, '')
开发者ID:BillWSY,项目名称:netfpga,代码行数:28,代码来源:netfpga.py


示例2: __init__

 def __init__(self):
     try:
         username=web.cookies().user
         password=web.cookies().pwd
         self.uid=get_isLoginOk(username,password)
     except:
         raise web.seeother("/login")
开发者ID:lujinda,项目名称:pylot,代码行数:7,代码来源:config.py


示例3: GET

 def GET(self, slug):
     query = web.input(curpage=1)
     curpage = query.curpage
     if slug:
         article = session.query(Article).filter(Article.slug == slug).first()
         comments = article.comments
         offset = (curpage - 1) * config.COMMENT_PAGE_LEN
         p = divmod(len(comments), config.COMMENT_PAGE_LEN)
         if p[1] > 0:
             pagecount = p[0] + 1
         else:
             pagecount = 1
         comments = comments[offset : offset + config.COMMENT_PAGE_LEN - 1]
         pages = util.pages(
             pagecount,
             curpage,
             10,
             "&".join("%s=%s" % (a, b) for a, b in query.items() if a != "curpage") + "#comment",
         )
         cookie = {
             "author": web.cookies(author="").author,
             "email": web.cookies(email="").email,
             "weburl": web.cookies(weburl="").weburl,
         }
         return render_blog.article_detail(locals(), self)
     else:
         return web.notfound("not found the page")
开发者ID:hellolibo,项目名称:pyblog,代码行数:27,代码来源:views.py


示例4: GET

 def GET(self,domain):
     domainId = processData.domainInfo(
                                     web.cookies().email,
                                     web.cookies().password,
                                     domain=domain
                                     )#获取域名ID
     
     recordList = processData.recordList(
                                     web.cookies().email,
                                     web.cookies().password,
                                     id=domainId
                                     )#获取记录列表
     fileHead = '主机|类型|线路|记录值|MX优先级|TTL'#导出文件的头部
     s = ''
     s += fileHead + '\n'
     for i in recordList:
         s += i['name'].encode() + '\t'
         s += str(i['type']) + '\t'
         s += i['line'].encode('utf-8') + '\t'
         s += str(i['value']) + '\t'
         s += str(i['mx']) + '\t'
         s += str(i['ttl']) + '\n'
     web.header('Content-Type','static/txt')
     web.header('Content-Disposition',"attachment;filename="+domain+".txt")
     return s
开发者ID:EugeneLiu,项目名称:dnspod,代码行数:25,代码来源:dnspod.py


示例5: POST

	def POST(self):
		data = web.input()

		username = data.get('username','')
		password = data.get('password','')
		remember = data.get('remember', '')

		if not username or not password:
			error_msg = u"用户名或密码不能为空!"
			return render.render('auth/login', username=username, error_msg=error_msg)
		else:
			password = hash_password(password)

			if not self.checkUser(username, password):
				error_msg = u'用户名或密码错误!'
				return render.render('auth/login', username=username, error_msg=error_msg)
			else:
				web.ctx.session.login = 1
				web.ctx.session.username = username

				# 记住密码一周
				if remember == 'on':
					expires = 7 * 24 * 60 * 60
					web.setcookie("username", username, expires)
					web.setcookie("password", password, expires)
				else:
					# 如果没有选择记住密码,清除cookie
					if web.cookies().get('username'):
						web.setcookie("username", username, -1)
					if web.cookies().get('password'):
						web.setcookie("password", password, -1)

				return web.seeother("/")
开发者ID:blankyin,项目名称:sports,代码行数:33,代码来源:auth.py


示例6: POST

    def POST(self):
        i = web.input()
        
        board_list = [u'校外教育', u'远程办公', u'智慧之门', u'美容美体', u'情感天地',
                      u'健康管理', u'娱乐人生', u'家政辅导', u'购物天堂', u'职业生涯',
                      u'社区服务',u'公共信息']
        
        board_id = board_list.index(i.board_id) + 1
        x = web.input(upload_pic={})
        f = None
        if 'upload_pic' in x:
            f = x['upload_pic'].value
            # upload a file
        headers2 = {
            'X-Token': web.cookies().get('token')
        }
        upload_res = requests.post(conf.locate('/attachments/upload'),
                                   data=f,
                                   headers=headers2)
        uuid = simplejson.loads(upload_res.text)
        uuid = uuid['id']
        payload = {
            'introduction': i.introduction
        }
        headers = {
            'X-Token': web.cookies().get('token'),
            'Content-Type': 'application/json'
        }
        res = requests.post(conf.locate('/pin/create/%s/%s' % (board_id, uuid)),
                            data=simplejson.dumps(payload),
                            headers=headers)

        return web.seeother('/controlskip/%s' % board_id)
开发者ID:poidea,项目名称:BigData_Web,代码行数:33,代码来源:upload.py


示例7: POST

 def POST(self,balabala):
     domainId = processData.domainInfo(
                                     web.cookies().email,
                                     web.cookies().password,
                                     domain=domain_g
                                     )#获取域名ID
     x = web.input(myfile={})
     count = 0
     k = 0
     for line in x['myfile'].file:
         line = line.split('\t')
         count += 1
         if count == 1 or line[3] == 'f1g1ns1.dnspod.net.' or line[3] == 'f1g1ns2.dnspod.net.':
             k += 1   
             continue
         message = processData.addRecord(
                                     web.cookies().email,#邮箱
                                     web.cookies().password,#密码
                                     domain_id=domainId,#域名ID
                                     sub_domain = line[0],#主机记录        
                                     record_type = line[1],#记录类型
                                     route_line = line[2],#线路类型
                                     value = line[3],#记录值
                                     mx = line[4],#MX值
                                     ttl = line[5][:-1]#TTL
                                     )        
     count -= k
     return render.upload(domain_g,msg='成功导入'+str(count)+'条记录,请点击左上角的域名进行查看!')
开发者ID:EugeneLiu,项目名称:dnspod,代码行数:28,代码来源:dnspod.py


示例8: checkToken

def checkToken():
    un = web.cookies().get('userName')
    tk = web.cookies().get('token')
    if(un and tk and ses):
        if(un == ses.userName and tk == ses.token):
            return True
    raise web.seeother('/login')
开发者ID:xltank,项目名称:pytest,代码行数:7,代码来源:app.py


示例9: GET

 def GET(self):
     cookies = web.cookies()
     if cookies.get("session") == None:
         web.seeother("http://www.tjhsst.edu/hackathon/login")
     templates = web.template.render('webvirt/templates/')
     myform = web.form.Form( 
         web.form.Textbox("name",web.form.notnull,description="Name of Virtual Machine: ",align='left'),
         web.form.Textbox("mem",web.form.notnull,web.form.regexp('\d+', 'Must be a digit'),description="Amount of Memory (in KiB): ",align='left'),
         web.form.Textbox("cpu",web.form.notnull,web.form.regexp('\d+', 'Must be a digit'),description="Number of Virtual Processors: ",align='left'),
         web.form.Textbox("hd",web.form.notnull,description='Full Path to hard drive file: ',align='left'),
         web.form.Textbox("iso",web.form.notnull,description="Full Path to cdrom iso file (e.x /var/hackfiles/gentoo.iso): ",align='left'),
         web.form.Textbox("vnc",web.form.notnull,description="VNC Port Number: ",align='left'),
         web.form.Textbox("pts",web.form.notnull,web.form.regexp('\d+', 'Must be a digit'),description="PTS number for serial console: ",align='left')
     )
     form = myform()
     data = ""
     content = "<h2>Create a New VM</h2>"
     for dom in conn.listAllDomains(0):
         dom = virt.Domain(dom)
         if(dom.rawstate == libvirt.VIR_DOMAIN_RUNNING):
             data += "<li><a href='/hackathon/vm?vm=" + dom.name + "'>" + dom.name + "<div class='pull-right'><span class='label label-success'>" + dom.state + "</span></div></a></li>"
         elif(dom.rawstate == libvirt.VIR_DOMAIN_SHUTOFF):
             data += "<li><a href='/hackathon/vm?vm=" + dom.name + "'>" + dom.name + "<div class='pull-right'><span class='label label-important'>" + dom.state + "</span></div></a></li>"
         else:
             data += "<li><a href='/hackathon/vm?vm=" + dom.name + "'>" + dom.name + "<div class='pull-right'><span class='label label-warning'>" + dom.state + "</span></div></a></li>"
     return templates.create(content, data,form,web.cookies().get("session"))
开发者ID:sdamashek,项目名称:webvirt,代码行数:26,代码来源:urls.py


示例10: auth_processor

def auth_processor(handler):
    path = web.ctx.path
    method = web.ctx.method
    if path == '/auth' and (method == 'POST' or method == 'GET'):
        return handler()
    else:
        name = web.cookies().get('user_name')
        passwd = web.cookies().get('user_passwd')

        if not name or not passwd:
            raise RestfulError('570 cookies auth error')

        # Note:
        # 1. switch system model for develop or release, must auth 'admin' user,
        #     'user' user has no permission.
        # 2. shutdown or reboot the mechine, must auth the user, only 'admin' can do.
        if path in ['/system/shutdown', '/system/reboot'] \
            or (path == '/system/startup-mode' and method == 'PUT'):
            # check user is 'admin'
            if name != 'admin':
                raise RestfulError("580 Auth Error: No permission, only admin can do this!")


        # filter chinese and other characters
        # rule = re.compile("^[\w-]+$")
        # if not rule.match(name) or not rule.match(passwd):
        #     raise RestfulError('570 name or passwd just support [0-9a-zA-Z_-] characters')

        ret = auth_user(name, passwd)
        if ret:
            return handler()
        else:
            raise RestfulError('570 auth failed')
开发者ID:wangdiwen,项目名称:system_mgm_tools,代码行数:33,代码来源:restful-server.py


示例11: POST

    def POST(self):
        i = web.input()
        print "1111111."
        print i.board_id
        boardlist = ['education', 'remotworking', 'intelligence', 'beauty', 'emotion', 'health_management',
                     'entertainment', 'Domestic_counseling', 'shopping', 'career', 'community_services',
                     'public_information']

        board_id = boardlist.index(i.board_id) + 1
        # buffer
        x = web.input(upload_pic={})
        f = None
        if 'upload_pic' in x:
            f = x['upload_pic'].value
            # upload a file
        headers2 = {
            'X-Token': web.cookies().get('token')
        }
        upload_res = requests.post(conf.locate('/attachments/upload'),
                                   data=f,
                                   headers=headers2)
        uuid = simplejson.loads(upload_res.text)
        uuid = uuid['id']
        payload = {
            'introduction': i.introduction
        }
        headers = {
            'X-Token': web.cookies().get('token'),
            'Content-Type': 'application/json'
        }
        res = requests.post(conf.locate('/pin/create/%s/%s' % (board_id, uuid)),
                            data=simplejson.dumps(payload),
                            headers=headers)

        return web.seeother('/controlskip/%s' % board_id)
开发者ID:snailhu,项目名称:BigData_Web,代码行数:35,代码来源:upload.py


示例12: clear_session

def clear_session():
	key = web.cookies().get('olin-auth-key')
	username = web.cookies().get('olin-auth-username')
	if key != None and username != None and verify_username(key, username):
		clear_keys(username)
	set_auth_cookie('olin-auth-key', "", 60*60*24*30)
	set_auth_cookie('olin-auth-username', "", 60*60*24*30)
开发者ID:olin,项目名称:ldap-auth-2012,代码行数:7,代码来源:auth.py


示例13: GET

    def GET(self):
        res = requests.get(conf.locate('/user/%s/profile' % web.cookies().get('key')))
        present_user = simplejson.loads(res.text)
        res = requests.get(conf.locate('/pin/user/%s' % web.cookies().get('key')))
        present_user_pin = simplejson.loads(res.text)
        pins = [[], [], [], []]
        for i, p in enumerate(present_user_pin['pins']):
            print "111111111222222"
            print p
            if p['type'] == 'movie':
                res = requests.get(conf.locate('/user/%s/profile' % p['author_id']))
                profile = simplejson.loads(res.text)
                i %= 4
                pin_obj = Pin(p, profile, present_user)
                pins[i].append(pin_obj.render_video())
            elif p['type'] == 'picture':
                res = requests.get(conf.locate('/user/%s/profile' % p['author_id']))
                profile = simplejson.loads(res.text)
                print profile
                i %= 4
                pin_obj = Pin(p, profile, present_user)
                pins[i].append(pin_obj.render())

        headers = {
            'X-Token': web.cookies().get('token')
        }

        res = requests.get(conf.locate('/following/%s' % web.cookies().get('key')), headers=headers)
        result = simplejson.loads(res.text)
        attentions = []
        for attention in result:
            attentions.append(str(pure_render.attention_list(attention)))
        attentions_len=len(attentions)
        
        return render.usermessage(pins, present_user, attentions,attentions_len)
开发者ID:poidea,项目名称:BigData_Web,代码行数:35,代码来源:controlskip.py


示例14: GET

 def GET(self):
   
   rdio, currentUser = get_rdio_and_current_user()
   
   if rdio and currentUser:
     user_id = int(currentUser['key'][1:])
     
     myPlaylists = rdio.call('getPlaylists')['result']['owned']
     
     db = get_db()
     
     result = list(db.select('discoversong_user', what='address, playlist', where="rdio_user_id=%i" % user_id))
     if len(result) == 0:
       access_token = web.cookies().get('at')
       access_token_secret = web.cookies().get('ats')
       db.insert('discoversong_user', rdio_user_id=user_id, address=make_unique_email(currentUser), token=access_token, secret=access_token_secret, playlist='new')
       result = list(db.select('discoversong_user', what='address, playlist', where="rdio_user_id=%i" % user_id))[0]
     else:
       result = result[0]
     
     message = ''
     if 'saved' in get_input():
       message = '  Saved your selections.'
     
     return render.loggedin(name=currentUser['firstName'],
                            message=message,
                            to_address=result['address'],
                            editform=editform(myPlaylists, result['playlist'])
                           )
   else:
     return render.loggedout()
开发者ID:JustinTulloss,项目名称:discoversong,代码行数:31,代码来源:app.py


示例15: GET

 def GET(self):
     try: 
         posts=db.posts
         query=posts.find({"user":web.cookies().user})
         usuario1 = query[0]["user"]
         password1 = query[0]["password"]
         nombre1 = query[0]["nombre"]
         apellidos1 = query[0]["apellidos"]
         correo1 = query[0]["correo"]
         dia1 = query[0]["dia"]
         mes1 = query[0]["mes"]
         anio1 = query[0]["anio"]
         direccion1 = query[0]["direccion"]
         pago1 = query[0]["pago"]
         visa1 = query[0]["visa"]
         res="Bienvenido usuario: %s " % (usuario1)
         web.setcookie('pagina3', web.cookies().pagina2)
         web.setcookie('pagina2', web.cookies().pagina1)
         web.setcookie('pagina1', "ver_perfil")
         web.header('Content-Type', 'text/html; charset=utf-8')
         return plantillas.datos_perfil(formulario=res, mensaje="", usuario = usuario1, password = password1, nombre= nombre1, apellidos=apellidos1, correo=correo1, dia=dia1, mes=mes1, anio=anio1, direccion=direccion1, pago=pago1, visa=visa1)
     except:
         l=form_log()
         web.header('Content-Type', 'text/html; charset=utf-8')
         return plantillas.pagina_desconectado(formulario=l.render(), mensaje="Se ha producido algun error. Inicie sesion de nuevo.")
开发者ID:JCristobal,项目名称:ProjectCC,代码行数:25,代码来源:script.py


示例16: POST

 def POST(self):
         my_login = login_form()
         if my_login.validates():
                 email = my_login['username'].value
                 password = my_login['password'].value
                 session_creation = CreateSession()
                 session_creation.session_hook()
                 print "INSIDE LOGIN PRINTING SESSION"
                 session_creation.add_hook()
                 print "THIS IS WHERE THE COOKIE SHOULD BE CREATED AND CALLED: "
                 print web.cookies()
                 result = handle_user(email, password, "login")
                 if (result == False):
                         print "something unexpected has occured"
                         my_login['username'].note = "Invalid Username/Password Combination"
                         return render.login(my_login)
                 else:
                         print "THIS MEANS YOU GOT VALIDATED BABY!(LOGIN)"
                         return render.myCitations([citation("Johnson v. Johnson", "Johnson v Johnson, 2008 SCC 9 at para 289, [2008] 1 SCR 190, Binnie J.", "4 Feb 2013", "Canadian Case")])
         else:
                 print "didn't validate baby! (LOGIN)"
                 print "note", my_signup['username'].note
                 print my_signup['username'].value
                 print my_signup['password'].value
                 if ((my_signup['username'].value == "") or (my_signup['username'].value == None)):
                         my_login['username'].note = "Please enter a valid username"
                         return render.login(my_login)
                 elif((my_signup['password'].value == "") or (my_signup['password'].value == None)):
                         my_login['password'].note = "Please enter a valid password"
                         return render.login(my_login)
                 else:
                         return render.login()
开发者ID:lreznick,项目名称:legalcitation,代码行数:32,代码来源:main_dev.py


示例17: get_view_settings

def get_view_settings(config_agent, simple = False):
    theme_name = config_agent.config.get("frontend", "theme_name")

    c_fp = config_agent.config.get("frontend", "show_full_path")
    show_full_path = int(web.cookies().get("zw_show_full_path", c_fp))

    c_toc = config_agent.config.getboolean("frontend", "auto_toc")
    auto_toc = int(web.cookies().get("zw_auto_toc", c_toc))

    c_hc = config_agent.config.get("frontend", "highlight_code")
    highlight_code = int(web.cookies().get("zw_highlight", c_hc))

    reader_mode = config_agent.config.getboolean("frontend", "reader_mode")

    show_quick_links = config_agent.config.getboolean("frontend", "show_quick_links")
    show_home_link = config_agent.config.getboolean("frontend", "show_home_link")

    button_mode_path = config_agent.config.getboolean("frontend", "button_mode_path")
    show_toolbox = True
    show_view_source_button = config_agent.config.getboolean("frontend", "show_view_source_button")

    if simple:
        auto_toc = False
        reader_mode = False
        highlight_code = False

    settings = dict(theme_name = theme_name,
                    show_full_path = show_full_path,
                    auto_toc = auto_toc, highlight_code = highlight_code, reader_mode = reader_mode,
                    show_quick_links = show_quick_links, show_home_link = show_home_link,
                    button_mode_path = button_mode_path,
                    show_toolbox = show_toolbox,
                    show_view_source_button = show_view_source_button)
    return settings
开发者ID:JoonyLi,项目名称:zbox_wiki,代码行数:34,代码来源:page.py


示例18: GET

  def GET(self):
    access_token = web.cookies().get('at')
    access_token_secret = web.cookies().get('ats')
    if access_token and access_token_secret:
      rdio = Rdio((RDIO_CONSUMER_KEY, RDIO_CONSUMER_SECRET),
        (access_token, access_token_secret))
      # make sure that we can make an authenticated call

      try:
        currentUser = rdio.call('currentUser')['result']
      except urllib2.HTTPError:
        # this almost certainly means that authentication has been revoked for the app. log out.
        raise web.seeother('/logout')

      myPlaylists = rdio.call('getPlaylists')['result']['owned']

      response = '''
      <html><head><title>Rdio-Simple Example</title></head><body>
      <p>%s's playlists:</p>
      <ul>
      ''' % currentUser['firstName']
      for playlist in myPlaylists:
        response += '''<li><a href="%(shortUrl)s">%(name)s</a></li>''' % playlist
      response += '''</ul><a href="/logout">Log out of Rdio</a></body></html>'''
      return response
    else:
      return '''
开发者ID:ColdSauce,项目名称:rdio-simple,代码行数:27,代码来源:web-based.py


示例19: check_login_state

def check_login_state():
    """
    If current user has logined in,
    return True,
    otherwise return False
    """
    username = web.cookies().get('user_name')
    if not username:
        return False

    logged_in = web.cookies().get('logged_in')
    if not logged_in:
        return False

    client_info = get_client_info()
    server_session = userstate.get_session()
    #server_ip = userstate.get_session('ip')
    #server_agent = userstate.get_session('agent')
    server_ip = server_session.ip
    server_agent = server_session.agent

    if not server_ip == client_info['ip']:
        return False

    if not server_agent == client_info['agent']:
        return False

    return True
开发者ID:minixalpha,项目名称:WatchTips,代码行数:28,代码来源:auth.py


示例20: get_rdio_and_current_user

def get_rdio_and_current_user(access_token=NOT_SPECIFIED, access_token_secret=NOT_SPECIFIED, request=True):

  if access_token and access_token_secret:
    try:
      rdio = get_rdio_with_access(access_token, access_token_secret)
      logging.error('got rdio %s' % rdio)
      # make sure that we can make an authenticated call
      currentUser = rdio.call('currentUser', {'extras': 'username'})['result']
      rdio_user_id = int(currentUser['key'][1:])
      if access_token == NOT_SPECIFIED and access_token_secret == NOT_SPECIFIED:
        access_token = web.cookies().get('at')
        access_token_secret = web.cookies().get('ats')
        db = get_db()
        db.update(USER_TABLE, where="rdio_user_id=%i" % rdio_user_id, token=access_token, secret=access_token_secret)
        logging.info('updated token and secret for user')
    except urllib2.HTTPError as ex:
      logging.exception(ex.message)
      # this almost certainly means that authentication has been revoked for the app. log out.
      if request:
        raise web.seeother('/logout')
      else:
        logging.error('could not get rdio with token and secret %s %s and cannot log out because not a web call' % (access_token, access_token_secret))
        return None, None, None
    except Exception as ex2:
      logging.exception(ex2.message)
      return None, None, None
    return rdio, currentUser, int(currentUser['key'][1:])
  else:
    return None, None, None
开发者ID:eae,项目名称:discoversong,代码行数:29,代码来源:rdio.py



注:本文中的web.cookies函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python web.data函数代码示例发布时间:2022-05-26
下一篇:
Python web.conflict函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap