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

Python web.input函数代码示例

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

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



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

示例1: POST

    def POST(self):
        if session.login != True:
            return render.message(site_prefix, "未登录", "您尚未登录", "", "_parent", "登录界面")
        seedid = web.input().productid
        productname = web.input().productname
        brand = web.input().brand   

        db = MySQLdb.connect(host = DB_HOST, user = DB_USER, passwd = DB_PASSWORD, db = DB_NAME, charset='utf8')
        cursor = db.cursor()

        #cmd = "SELECT id FROM type WHERE name='%s';" % producttype
        #cursor.execute(cmd)
        #producttype = cursor.fetchone()[0]             

        #cmd = "SELECT * FROM devices WHERE id='%s' and brand='%s';" % (seedid, brand)
        #cursor.execute(cmd)
        #rows = cursor.fetchall()

        #if productid != session.oldid and len(rows) != 0:
        #    db.close()
        #    return render.message(site_prefix, "修改失败", "产品唯一标识重复", "modify?id=" + str(session.oldid), "main", "重新修改")

        #else:
        #now = time.strftime("%Y-%m-%d %H:%M:%S")
        cmd = "UPDATE devices SET seedid = '%s', name = '%s', brand = '%s' WHERE id = '%s'" % (seedid, productname, brand, session.oldid) 
        cursor.execute(cmd)
        db.close()
    

        return render.message(site_prefix, "修改成功", "产品信息修改成功", "manage", "main", "产品管理")   
开发者ID:dalinhuang,项目名称:seed,代码行数:30,代码来源:manage.py


示例2: GET

 def GET(self):
     action = web.input().get('act')
     username = web.input().get("u")
     url = web.input().get("url")
     if not username or not url or not action:
         return "Some parameter is missing or wrong!<br />"
     
     user = KeUser.all().filter("name = ", username).get()
     if not user or not user.kindle_email:
         return "User not exist!<br />"
     
     #global log
     
     url = urllib.unquote(url)
     
     #debug_mail(content)
     
     if action in ('evernote', 'wiz'): #保存至evernote/wiz
         return self.SaveToEvernoteWiz(user, action, url)    
     elif action == 'pocket': #保存到pocket
         return self.SaveToPocket(user, action, url)
     elif action == 'instapaper':
         return self.SaveToInstapaper(user, action, url)
     else:
         return "Unknown action type : %s !" % action
开发者ID:644026044,项目名称:KindleEar,代码行数:25,代码来源:Share.py


示例3: POST

    def POST(self):
        context = web.input().context.encode('utf-8')
        taskid = web.input().taskid
        file_name = web.input().file_name

        # Only segement the title and keyword
        seg_content = []
        lines = context.split('\r')
        for line in lines:
            tmp = line.split('\t')
            seg_content.append(tmp[1])
            seg_content.append(tmp[2])

        results = get_seg_result('\t'.join(seg_content), keep_return=True)
        newcontent = assemble_result(context, results['filtered_result'], taskid=taskid, file_name=file_name)

        # log_message('Task ' + taskid + ' is excecuted (post), result: ' + '<br /> '.join(newcontent))

        # submit to server
        try:
            # payload = urllib.urlencode([('seg_result', ''.join(newcontent).encode('utf-8')), ('taskid', taskid), ])
            # req = urllib2.urlopen(SUBMIT_RESULT_URL, payload)
            # log_message('submit task ' + str(taskid) + ' to server' + req.read())
            from sae.storage import Bucket
            bucket = Bucket('mozillaup')
            bucket.put_object(file_name + '/' + str(taskid), ''.join(newcontent).encode('utf-8'))
            # log_message('submit task ' + str(taskid) + ' to bucket')
        except Exception, ex:
            print ex
            result = 'Encounter an error when submit task' + type(ex).__name__ + ' ' + str(ex.args)
            log_message(result)
开发者ID:PinZhang,项目名称:up-sae-segmentation,代码行数:31,代码来源:handlers.py


示例4: POST

    def POST(self):
        username, password = web.input().username, web.input().password

        # retreive user's salt
        try:
            salt = db.select("users", where="username=$username", vars=locals())[0]["salt"]
        except:
            return homepage_render.login("Login Error", session.loggedin)

        password = check_password(password, salt)

        # hash password with salt
        check = db.select("users", where="username=$username AND passwordhash=$password", vars=locals())

        if check:
            favouriteslist = pickle.loads(
                str(db.select("users", where="username=$username", vars=locals())[0]["favourites"])
            )
            favouritesusernamelist = []

            for favourite in favouriteslist:
                favourite = db.select("users", where="id=$favourite", vars=locals())[0]["username"]
                favouritesusernamelist.append(favourite)

            print favouritesusernamelist
            session.favourites = favouritesusernamelist
            session.loggedin = True
            session.username = username
            raise web.seeother("/")
        else:
            return homepage_render.login("Login Failed", session.loggedin)
开发者ID:christophski,项目名称:moodboard,代码行数:31,代码来源:auto.py


示例5: SaveToPocket

    def SaveToPocket(self, user, action, orgUrl):
        INSTAPAPER_API_ADD_URL = 'https://www.instapaper.com/api/add'

        web.header('Content-type', "text/html; charset=utf-8")
        
        T_INFO = u"""<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            <title>%s</title></head><body><p style="text-align:center;font-size:1.5em;">%s</p></body></html>"""
        if not user.pocket_access_token:
            info = T_INFO % ('Pocket unauthorized', 'Unauthorized Pocket!<br/>Please authorize your KindleEar application firstly.')
            return info.encode('utf-8')
            
        title = web.input().get('t', '')
        tkHash = web.input().get("h", '')
        if hashlib.md5(user.pocket_acc_token_hash).hexdigest() != tkHash:
            info = T_INFO % ('Action rejected', 'Hash not match!<br/>KindleEar refuse to execute your command.')
            return info.encode('utf-8')
            
        pocket = Pocket(POCKET_CONSUMER_KEY)
        pocket.set_access_token(user.pocket_access_token)
        try:
            item = pocket.add(url=orgUrl, title=title, tags='KindleEar')
        except Exception as e:
            info = T_INFO % ('Failed to save', _('Failed save to Pocket.<br/>') + str(e))
        else:
            info = _("'%s'<br/><br/>Saved to your Pocket account.") % title
            info += u'''<br/><p style="text-align:right;color:red;">by KindleEar &nbsp;</p>
                <br/><hr/><p style="color:silver;">'''
            info += _('See details below:<br/><br/>%s') % repr(item)
            info = T_INFO % ('Saved to pocket', info)
        
        return info.encode('utf-8')
开发者ID:644026044,项目名称:KindleEar,代码行数:31,代码来源:Share.py


示例6: GET

    def GET(self):
        es = Elasticsearch(conf['fulltext']['serviceUrl'])
        if web.input(wildcard_query=None).wildcard_query:
            query = {
                "wildcard": {
                    "_all": web.input().query
                }
            }
            self.set_wildcard_query(True)
        else:
            query = {
                "multi_match": {
                    "query": web.input().query,
                    "operator": "and",
                    "fields": ["text", "pageName", "tags"]
                }
            }
            self.set_wildcard_query(False)
        res = es.search(index=conf['fulltext']['indexName'],
                        body={"query": query,
                              "fields": ["pageName", "path", "fsPath", "text"]})
        rows = []
        for a in res['hits']['hits']:
            fields = a['fields']

            fs_path = os.path.normpath('%s/%s.md' % (self.data_dir, fields['path'][0]))
            page_chapters, h1 = extract_description(fs_path)
            rows.append({
                'h1': h1 if h1 else fields['path'][0],
                'file': fields['path'][0],
                'chapters': page_chapters
            })
        values = dict(query=web.input().query, ans=rows)
        return self._render('search.html', values)
开发者ID:tomachalek,项目名称:riki,代码行数:34,代码来源:app.py


示例7: GET

 def GET(self):
     triples = self._triples(web.input().get('url',''))
     callback = web.input().get('callback')
     if callback:
         return "%s(%s)" % (callback, renderer.response(triples))
     else:
         return renderer.response(triples)
开发者ID:creativecommons,项目名称:deedscraper,代码行数:7,代码来源:app.py


示例8: POST

    def POST(self):
        title = web.input().title
        tags = web.input().tags.split()
        mdName = web.input().filename
        mdSummary = web.input().summary
        fileSrc = web.input().mdfile.decode('utf8')

        newPost = Post(
            title=title,
            upload=datetime.now(),
            modified=datetime.now(),
            summary=mdSummary,
            filename=mdName
        )
        web.ctx.orm.add(newPost)
        web.ctx.orm.flush()

        for tag in tags:
            checkTag = web.ctx.orm.query(Tag).filter_by(name=tag).all()
            if not checkTag:
                newTags = Tag(name=tag)
                web.ctx.orm.add(newTags)
                web.ctx.orm.flush()

            newPost.tags.append(newTags)

        fout = open('articles/'+mdName, 'w')
        fout.write(fileSrc)
        fout.close()
        return json.dumps({
            'success': True
        })
开发者ID:icefeng,项目名称:blog.flexops.org,代码行数:32,代码来源:manager.py


示例9: POST

 def POST(self, path):
     if path == '/multipart':
         i = web.input(file={})
         return i.file.value
     else:
         i = web.input()
         return repr(dict(i)).replace('u','')
开发者ID:FrankSun0634,项目名称:webpy,代码行数:7,代码来源:application.py


示例10: POST

 def POST(self):
     print web.input()
     userID = web.input()["userID"]
     matchID = web.input()["matchID"]
     message = web.input()["message"]
     usersList[matchID].addMessage(userID, message)
     print userID, matchID, message
开发者ID:arroganharrison,项目名称:sddf2014,代码行数:7,代码来源:index.py


示例11: POST

 def POST(self):
     username, password = web.input().username, web.input().password
     web.ctx.session.login, web.ctx.session.uid = models.checkAdmin(username, password)
     if web.ctx.session.login > 0:
         return "login succeed."
     else:
         return "username or password error"
开发者ID:Orpine,项目名称:Library-Management-System,代码行数:7,代码来源:Admin.py


示例12: POST

    def POST(self, selector):

        try:
            assert selector != 'software'
            if selector == 'publicdomain':
                lclass = cc.license.selectors.choose('zero')
            else:
                lclass = cc.license.selectors.choose(selector)
        except:
            return api_exceptions.invalidclass()

        if not web.input().get('answers'):
            return api_exceptions.missingparam('answers')

        try:
            answers_xml = web.input().get('answers')
            if selector == 'publicdomain':
                answers_xml = answers_xml.replace(
                    '<license-publicdomain>',
                    '<license-zero>').replace(
                    '</license-publicdomain>',
                    '</license-zero>')
            
            # parse the answers argument into an xml tree
            answers = ET.parse(StringIO(answers_xml))
            
        except ET.XMLSyntaxError, e:
            return api_exceptions.invalidanswer()
开发者ID:doigoid,项目名称:cc.api,代码行数:28,代码来源:license.py


示例13: modify_post

    def modify_post(self, board_name, board_id, current_uid = -1):
        board_info = board.get_board_info(board_id)
        if not acl.is_allowed('board', board_id, current_uid, 'modify'):
            return util.render().error(error_message=_('NO_PERMISSION'), help_context='error')
        data = web.input()
        comment = 1 if data.has_key('commentable') else 0
        write_by_other = 1 if data.has_key('writable') else 0
        indexable = 1 if data.has_key('indexable') else 0
        show_avatar = 1 if data.has_key('show_avatar') else 0

        owner_uid = user._get_uid_from_username(web.input().owner)
        if owner_uid < 0:
            return util.render().error(error_message=_('NO_SUCH_USER_FOR_BOARD_ADMIN'), help_context='error')

        board_info = dict(path = data.path, name = data.name,
                owner = owner_uid, board_type = int(data.type),
                can_comment = comment, can_write_by_other = write_by_other,
                indexable = indexable, show_avatar = show_avatar,
                stylesheet = data.stylesheet,
                description = data.description,
                cover = data.information)
        result = board.board_edit(current_uid, board_id, board_info)
        if result[0] == False:
            return util.render().error(error_message = result[1], help_context='error')
        else:
            raise web.seeother(util.link('%s') % result[1])
开发者ID:peremen,项目名称:noah3k,代码行数:26,代码来源:web_board.py


示例14: write_post

    def write_post(self, board_name, board_id, current_uid = -1):
        a = dict(title = web.input().title, body = web.input().content)
        board_info = board.get_board_info(board_id)
        ret = article.write_article(current_uid, board_id, a)
        if ret[0] == True:
            user.update_unreaded_articles_board(current_uid, board_id)
            user.read_article(current_uid, ret[1])

            fs = web.ctx.get('_fieldstorage')
            try:
                if fs.has_key('new_attachment'):
                    new_attachment = fs['new_attachment']
                    if type(new_attachment) == list:
                        for f in new_attachment:
                            attachment.add_attachment(ret[1], f.filename, f.value)
                    else:
                        try:
                            attachment.add_attachment(ret[1], new_attachment.filename, new_attachment.value)
                        except:
                            pass
            except:
                pass
            url = util.link('/%s/+read/%s' % (board_name, ret[1]))
            raise web.seeother(url)
        else:
            return util.render().error(error_message = ret[1], help_context='error')
开发者ID:peremen,项目名称:noah3k,代码行数:26,代码来源:web_board.py


示例15: GET

 def GET(self):
     user = self.getcurrentuser()
     delurlid = web.input().get('delurlid')
     delwlist = web.input().get('delwlist')
     if delurlid:
         try:
             delurlid = int(delurlid)
         except:
             pass
         else:
             flt = UrlFilter.get_by_id(delurlid)
             if flt:
                 flt.delete()
     if delwlist:
         try:
             delwlist = int(delwlist)
         except:
             pass
         else:
             wlist = WhiteList.get_by_id(delwlist)
             if wlist:
                 wlist.delete()
     return jjenv.get_template('advsetting.html').render(nickname=session.username,
         title="Advanced Setting",current='advsetting',user=user,
         urlfilters=UrlFilter.all(),whitelists=WhiteList.all())
开发者ID:chenmsster,项目名称:KindleEar,代码行数:25,代码来源:main.py


示例16: POST

 def POST(self):
     form = novel_form() 
     if not form.validates(web.input(_method="POST")): 
         return render_to_response("admin/add_novel", {
             "form": form,
         })
     else:
         args = web.input(_method="post", rid=None)
         next = "/tuoshui_admin/checkall"
         if args.rid:
             next = "/tuoshui_admin/checkall_recommends"
         del args.rid
         # 获得type
         args.type = get_type_by_url(args.url)
         if not args.type:
             return "type_error"
         ret = self.db.add_novel(args)
         if ret[0] is True:
             rid = web.input(_method="get", rid=None).rid
             # 修改推荐小说的状态
             if rid:
                 self.db.update_recommend_status(rid)
             raise web.seeother(next)
         else:
             return ret
开发者ID:IthacaDream,项目名称:nowater_web,代码行数:25,代码来源:admin.py


示例17: POST

 def POST(self):
     name, passwd = web.input().get('u'), web.input().get('p')
     if name.strip() == '':
         tips = u"用户名为空! "
         return jjenv.get_template("login.html").render(nickname='',
             title='Login',tips=tips)
     elif len(name) > 25:
         tips = u"用户名限制为25个字符! "
         return jjenv.get_template("login.html").render(nickname='',
             title='Login',tips=tips,username=name)
     elif '<' in name or '>' in name or '&' in name:
         tips = u"用户名包含非法字符! "
         return jjenv.get_template("login.html").render(nickname='',
             title='Login',tips=tips)
     
     pwdhash = hashlib.md5(passwd).hexdigest()
     u = KeUser.all().filter("name = ", name).filter("passwd = ", pwdhash).get()
     if u:
         session.login = 1
         session.username = name
         if u.expires: #用户登陆后自动续期
             u.expires = datetime.datetime.utcnow()+datetime.timedelta(days=180)
             u.put()
         raise web.seeother(r'/')
     else:
         tips = u"用户名不存在或密码错误! "
         session.login = 0
         session.username = ''
         session.kill()
         return jjenv.get_template("login.html").render(nickname='',
             title='Login',tips=tips,username=name)
开发者ID:chenmsster,项目名称:KindleEar,代码行数:31,代码来源:main.py


示例18: POST

 def POST(self):
     name, passwd = web.input().get("u"), web.input().get("p")
     if name.strip() == "":
         tips = _("Username is empty!")
         return self.render("login.html", "Login", nickname="", tips=tips)
     elif len(name) > 25:
         tips = _("The len of username reached the limit of 25 chars!")
         return self.render("login.html", "Login", nickname="", tips=tips, username=name)
     elif "<" in name or ">" in name or "&" in name:
         tips = _("The username includes unsafe chars!")
         return self.render("login.html", "Login", nickname="", tips=tips)
     try:
         pwdhash = hashlib.md5(passwd).hexdigest()
     except:
         u = None
     else:
         u = KeUser.all().filter("name = ", name).filter("passwd = ", pwdhash).get()
     if u:
         session.login = 1
         session.username = name
         if u.expires:  # 用户登陆后自动续期
             u.expires = datetime.datetime.utcnow() + datetime.timedelta(days=180)
             u.put()
         raise web.seeother(r"/")
     else:
         tips = _("The username no exist or password is wrong!")
         # session.login = 0
         # session.username = ''
         # session.kill()
         return self.render("login.html", "Login", nickname="", tips=tips, username=name)
开发者ID:jackyueq,项目名称:KindleEar,代码行数:30,代码来源:main.py


示例19: POST

  def POST( self, get_string='' ):
    log.loggit( 'update.POST()' )

    # Must be a matching user or administrator to update
    wputil.must_match_username_or_admin( web.input()['username'] )

    # Catch the cancel button
    if  web.input().has_key('cancel'):
      if wputil.is_admin():
        raise web.seeother('../')
      else:
        raise web.seeother('../../')

    # Validate the form
    if wputil.is_admin():
      f = admin_account_form()
    else:
      f = account_form()
    if not f.validates():
      return { 'status' : 'error',
               'message' : 'Verify all information has been provided correctly.',
               'form' : f }

    # update the account in the database
    adb = accountdb.AccountDB()
    try:
      account = adb.update_account( f.d )
    except:
      return { 'status' : 'error',
               'message' : 'An error occurred updating the account.',
               'form' : f }

    raise web.seeother( '../review/%s' % (account['username']) )
开发者ID:5n1p,项目名称:webpy-example,代码行数:33,代码来源:account_update.py


示例20: GET

 def GET(self):
     self.login_required("admin")
     # 可以修改UrlEncoding,如果chardet自动检测的编码错误的话
     action = web.input().get("action")
     if action == "modurlenc":
         id = int(web.input().get("id", 0))
         feedenc = web.input().get("feedenc")
         pageenc = web.input().get("pageenc")
         urlenc = UrlEncoding.get_by_id(id)
         if urlenc:
             if feedenc:
                 urlenc.feedenc = feedenc
             if pageenc:
                 urlenc.pageenc = pageenc
             urlenc.put()
     elif action == "delurlenc":
         id = int(web.input().get("id", 0))
         urlenc = UrlEncoding.get_by_id(id)
         if urlenc:
             urlenc.delete()
     return self.render(
         "dbviewer.html",
         "DbViewer",
         books=Book.all(),
         users=KeUser.all(),
         feeds=Feed.all().order("book"),
         urlencs=UrlEncoding.all(),
     )
开发者ID:jackyueq,项目名称:KindleEar,代码行数:28,代码来源:main.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python web.internalerror函数代码示例发布时间:2022-05-26
下一篇:
Python web.htmlquote函数代码示例发布时间: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