本文整理汇总了Python中web.input函数的典型用法代码示例。如果您正苦于以下问题:Python input函数的具体用法?Python input怎么用?Python input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了input函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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", "产品管理")
示例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
示例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)
示例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)
示例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 </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')
示例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)
示例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)
示例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
})
示例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','')
示例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
示例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"
示例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()
示例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])
示例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')
示例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())