本文整理汇总了Python中web.data函数的典型用法代码示例。如果您正苦于以下问题:Python data函数的具体用法?Python data怎么用?Python data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了data函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: POST
def POST(self, service):
username = authenticate_user(web)
# If username is None: return wsse_auth error
for DIR in [RAWPOSTDATA_DIR, CACHE_DIR]:
if os.path.isdir(DIR) == False:
os.makedirs(DIR)
post_file = shareonline._save_post_data(web.data(), RAWPOSTDATA_DIR, username + '-request')
contentfile_name = os.path.basename(post_file)
#contentfile_body = os.path.splitext(post_file)[0]
data = shareonline._parse_request_xml(web.data())
if 'filedata' in data:
if 'filetype' in data:
content_filepath = get_filename(post_file, data)
with open(content_filepath, 'wb') as f:
f.write(data['filedata'])
del data['filedata']
print data
else: # read original post
print data
post = os.path.join(RAWPOSTDATA_DIR, data['uid'])
with open(post, 'rb') as f:
postdata = f.read()
data = shareonline._parse_request_xml(postdata)
del data['filedata']
web.header('Content-Type', 'application/atom+xml; charset=UTF-8')
data['id'] = contentfile_name
data['link'] = "/entry/" + contentfile_name
#print data
entry_xml = shareonline.create_entry(data)
#print entry_xml
web.Created()
shareonline._save_post_data(entry_xml, RAWPOSTDATA_DIR, username + '-response')
return entry_xml
开发者ID:aapris,项目名称:py-shareonline,代码行数:33,代码来源:test_server.py
示例2: POST
def POST(self):
request = None
config.read(config_file)
try:
dpctl_command = config.get("main", "dpctl_command")
except Exception as e:
pass
try:
request = cjson.decode(web.data())
except Exception as e:
logger.debug("PROBLEM: %s: %s" % (e.__str__(), web.data()))
return "PROBLEM: ", e.__str__()
try:
result = OSCARSRequestHandler(None, request).handle()
except Exception as e:
logger.error(e.__str__())
return e.__str__()
web.header('Content-Type', 'application/json')
return result
开发者ID:carriercomm,项目名称:oscars,代码行数:25,代码来源:oscars_openflow.py
示例3: POST
def POST(self):
if not web.data():
raise web.BadRequest
global scheduler
data = json.loads(web.data())
function = None
date = datetime.strptime(data["date"], "%d/%m/%Y %H:%M:%S")
task_type = data["task_type"]
if task_type == TaskType.ARM_ALARM:
function = arm_alarm
elif task_type == TaskType.DISARM_ALARM:
function = disarm_alarm
elif task_type == TaskType.TURN_ON_HEATING:
function = turn_on_heating
elif task_type == TaskType.TURN_OFF_HEATING:
function = turn_off_heating
# if the date has already occurred or no function has been selected
if date <= datetime.now() or function is None:
return web.badrequest()
else:
scheduler.add_task(function, date, task_type)
开发者ID:Sheehan95,项目名称:home-management-system,代码行数:26,代码来源:WebServer.py
示例4: parse_action_impl
def parse_action_impl(self, action, table, db):
if action == 'add_user_message':
user_id = self.qs_dict.get('user_id')
if not user_id:
set_status_code(web, 400)
return result_template('''Illegal parameters: no "user_id"''')
user_id = ''.join(user_id)
if debug:
web.debug('DB action=add_user_message, user_id=%s' % (user_id))
data = web.data()
db.add_user_message(user_id, data)
return ''
elif action == 'get_user_message':
user_id = self.qs_dict.get('user_id')
if not user_id:
set_status_code(web, 400)
return result_template('''Illegal parameters: no "user_id"''')
user_id = ''.join(user_id)
if debug:
web.debug('DB action=get_user_message, user_id=%s' % (user_id))
data = db.get_user_message(user_id)
return message_template(user_id, data)
elif action == 'remove_user_message':
user_id = self.qs_dict.get('user_id')
if not user_id:
set_status_code(web, 400)
return result_template('''Illegal parameters: no "user_id"''')
user_id = ''.join(user_id)
if debug:
web.debug('DB action=get_user_message, user_id=%s' % (user_id))
data = web.data()
list1 = json.loads(data);
db.remove_user_message(user_id, list1, web)
return ''
开发者ID:lao5-team,项目名称:dashen6-server,代码行数:34,代码来源:query_parser.py
示例5: default_post
def default_post(self, name):
# default name is 'timedata'
#result = {}
print 'name:', name
print web.ctx.query, '4444444444'
print web.data(), '3eeeeeeeeeee'
querydata = self.query_to_value()
postdata = self.json_loads(web.data())
print querydata, postdata, '111111111111'
a = time.localtime(time.time())
hour, minute, second = a[3], a[4], a[5]
currentsecond = '%02d:%02d:%02d' % (hour, minute, second)
#currentsecond = 'test'
if self._citydict.get(currentsecond, ' ') == ' ':
self._citydict[currentsecond] = {}
for each in postdata:
if self._citydict[currentsecond].get(each, ' ') == ' ':
self._citydict[currentsecond][each] = postdata[each]
else:
self._citydict[currentsecond][each] += postdata[each]
print self._citydict, '5555555555555'
#if name != 'otherspost':
# for each in self._totalservicelist:
# post_service_data(each['host'], each['port'], 'otherspost', web.data())
return {'result' : '0'}
开发者ID:jizhouli,项目名称:realtime-booking-board,代码行数:27,代码来源:service_interface_20150525.py
示例6: POST
def POST(self, name):
"""Add titles to an existing work"""
logger.debug("Data: %s" % (web.data()))
data = json.loads(web.data())
title = data.get('title')
work_id = data.get('UUID') or data.get('uuid')
try:
titles = strtolist(title)
assert titles and work_id
except AssertionError as error:
logger.debug(error)
raise Error(BADPARAMS, msg="You must provide a (work) UUID"
+ " and at least a title")
try:
work = Work(work_id, titles=titles)
assert work.exists()
except:
raise Error(BADPARAMS, msg="Unknown work '%s'" % (work_id))
work.save()
work.load_titles()
work.load_identifiers()
return [work.__dict__]
开发者ID:baconwaffles,项目名称:identifier_translation_service,代码行数:27,代码来源:titlesctrl.py
示例7: POST
def POST(self):
try:
rawdata = json.loads(web.data())
except ValueError as e:
raise self.error("Unparseable JSON input \n %s"%web.data())
# step 1: prepare the data
data = self.prepare_input_data(rawdata)
# step 2: search
matches = self.search(data)
# step 3: Check auth
try:
auth_header = http_basic_auth()
self.login(auth_header)
except accounts.ClientException:
raise self.auth_failed("Invalid credentials")
# step 4: create if logged in
keys = []
if auth_header:
keys = self.create(matches)
# step 4: format the result
d = self.format_result(matches, auth_header, keys)
return json.dumps(d)
开发者ID:hornc,项目名称:openlibrary-1,代码行数:27,代码来源:code.py
示例8: POST
def POST(self):
try:
tid_value = web.input()['tid']
except KeyError:
return web.BadRequest()
try:
team_id = cfg['TEAM_ID_DICT'][tid_value.upper()]
except KeyError:
return web.Unauthorized()
if len(web.data()) == 0:
return web.BadRequest()
data = simplejson.loads(web.data())
# json validation
good, errors = IssueValidator().validate(data)
if not good:
return errors
r = requests.post(''.join(['http://', cfg['REMOTE_HOST'], '/pp']), data=simplejson.dumps({'tid': str(team_id), 'iid': data['ID']}))
if r.status_code != 200:
print 'Call remote server failed...'
print r.text
api = WxApi(cfg['CORP_ID'], cfg['SECRET'])
api.send_text(self.build_msg(data), team_id, 0, '@all')
return web.OK('ok')
开发者ID:bikongyouran,项目名称:AlertService,代码行数:29,代码来源:internal_server.py
示例9: POST
def POST(self):
print web.input()
print web.data()
params=web.input()
openid=params.openid if hasattr(params, "openid") else ""
data=web.data()
root = xml.etree.ElementTree.XML(data)
toUserName= root.findall("ToUserName")
fromUserName= root.findall("FromUserName")
content= root.findall("Content")
retXml=u"""
<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%d</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[%s]]></Content>
</xml>
"""
retXml=retXml % (fromUserName[0].text,toUserName[0].text,int(round(time.time())),content[0].text)
print retXml.encode("utf-8")
return retXml
开发者ID:meiavy,项目名称:python-weixin,代码行数:25,代码来源:weixin.py
示例10: POST
def POST(self, name, ext):
if not corpora.has_key(name):
yield web.notfound()
return
try:
c = corpora[name]['reader']
params = web.input()
offset = int(params.get('start', '0'))
# Do we want to highlight something?
if params.has_key('markerQuery') and params.has_key('markerAttr') and params.has_key('markerValue'):
markerQueries = [alpinocorpus.MarkerQuery(params['markerQuery'].encode('utf-8'),
params['markerAttr'], params['markerValue'])]
else:
markerQueries = []
# Was a query provided?
if params.has_key('query'):
gen = c.queryWithStylesheet(params['query'].encode('utf-8'), web.data(), markerQueries, _timeout)
else:
gen = c.entriesWithStylesheet(web.data(), markerQueries, _timeout)
for i in self.run(gen, ext, True, offset):
yield i
except:
print sys.exc_info()
yield web.internalerror()
开发者ID:andreasvc,项目名称:alpinocorpus-python,代码行数:30,代码来源:server.py
示例11: POST
def POST(self):
fromNum=re.findall('(?<=From=%2B1)(.*)(?=&ApiVersion=)', web.data())[0]
verification_code=db.query('SELECT verification_code FROM users WHERE id=' + str(session.get('id')))[0]['verification_code']
if not verification_code==1:
message = client.messages.create(body="Sorry bud, you haven't verified this number yet!",
to="+1" + fromNum, # Replace with your phone number
from_="+16103475899") # Replace with your Twilio number
else:
response = twiml.Response()
#body = request.form['Body']
msg=re.findall('(?<=&Body=)(.*)(?=&FromCountry)', web.data())[0]
account_sid=""
auth_token=""
client = TwilioRestClient(account_sid, auth_token)
#from http://stackoverflow.com/a/8768241
regex_date='^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})'
#from http://stackoverflow.com/a/7536768
regex_time='([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]'
msg_date=re.findall(regex_date, msg)[0]
msg_time=re.findall(regex_time, msg)[0]
msg_description=re.findall("(?<=[0-9]:[0-9][0-9] )(.*)", msg)[0]
message = client.messages.create(body="I've set your schedule for " + msg_date + " at " + msg_time + " for " + msg_description,
to="+1" + fromNum, # Replace with your phone number
from_="+") # Replace with your Twilio number
print message.sid
开发者ID:chackerian,项目名称:Scheduler,代码行数:30,代码来源:main.py
示例12: POST
def POST(self):
options = web.input(_method='get')
options = {'semantics' : 'drg'}
drg, _ = run(web.data(), ['tokenizer', 'soap_client', 'boxer'], options)
png(drg.split('\n')[:-2], TMPPNG)
log.info('[drg] {}'.format(web.data()))
return open(TMPPNG,"rb").read()
开发者ID:valeriobasile,项目名称:candcapi,代码行数:7,代码来源:server.py
示例13: POST
def POST(self):
data = web.data()
data = json.loads(web.data())
print "New commit by: {}".format(data['commits'][0]['author']['name'])
print "Time: {}".format(data['commits'][0]['timestamp'])
print "Message: {}".format(data['commits'][0]['message'])
print data['ref']
return 'OK'
开发者ID:Perunity-cPlusPlusGameDev,项目名称:Github-GoogleHangouts-Bot,代码行数:8,代码来源:hooks.py
示例14: POST
def POST(self):
import logging
logger = logging.getLogger()
logger.debug(str(web.data()))
from application.msgservice import MsgService
msgservice = MsgService()
msgservice.sendMessage(str(web.data()))
return ""
开发者ID:gerza,项目名称:webhook,代码行数:8,代码来源:rest.py
示例15: POST
def POST(self):
if len(web.data()) == 0:
raise Exception('No data')
req = web.data()
color = _color_from_hex(req)
action.add(color)
return {}
开发者ID:mtyka,项目名称:grooviks3,代码行数:8,代码来源:web_server.py
示例16: POST
def POST(self):
ops = json.loads(web.data())
if web.data() == "-1":
web.header('Content-Type', 'application/json')
return json.dumps(list(DBA.getAllItems()))
else:
web.header('Content-Type', 'application/json')
return json.dumps(DBA.getItem(web.data()))
开发者ID:amtunlimited,项目名称:cap-project,代码行数:8,代码来源:cap.py
示例17: PUT
def PUT(self, game_id):
game_id = int(game_id)
if (len(web.data()) > 0):
# TODO(david): parse based on Content-Type
req = json.loads(web.data())
if ('cube' in req):
# TODO(david): validate that the new cube state is legal
games.game(game_id)['cube'] = req['cube']
return { RESULT: games.game(game_id) }
开发者ID:mtyka,项目名称:grooviks3,代码行数:9,代码来源:web_server.py
示例18: _POST
def _POST(self, key, forceful=False):
if forceful:
self.datastore.set_value_in_all(str(key), web.data())
else:
self.datastore.set_value(str(key), web.data())
web.created()
location = "".join([web.ctx.home, _url_formatter(str(key))])
web.header("Location", location)
return {"message": location}
开发者ID:Hallx,项目名称:datastore,代码行数:9,代码来源:controller.py
示例19: POST
def POST(self):
web.header('Content-Type', 'application/json')
data = web.input()
data["contentType"] = web.ctx.env["CONTENT_TYPE"]
if data["contentType"] == "application/json":
data["json"] = json.loads(web.data())
else:
data["pars"] = web.data()
data["method"] = "POST"
return json.dumps(data)
开发者ID:eelcodijkstra,项目名称:html3-rest,代码行数:10,代码来源:les3.py
示例20: POST
def POST(self, params):
try:
if params.startswith('statuses/update.'):
web.ctx.data = self.update_filter(web.data())
return BaseProxy.POST(self, params)
except Exception, why:
import traceback
logger.error("%s %s %s" % (params, str(why), web.data()))
logger.error(traceback.format_exc())
web.internalerror()
开发者ID:sinsinpub,项目名称:sin2gae,代码行数:10,代码来源:code.py
注:本文中的web.data函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论