Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def template_sets_unionstore():
destination_key = request.POST.get('destkey', '').strip()
key = request.POST.get('key', '').strip()
keys = string.split(key, ',')
tuple_keys = tuple(keys)
unionstore = r.sunionstore(destination_key, tuple_keys)
return dictWithAddedCommonFields(key=key, returned_value=unionstore)
def snapshot(db):
bid = request.POST.get('bookmarkid','')
if not needarchive(db):
return {'error' : '请启用CopyCat服务信息'}
if not archiveapiok(db):
return {'error' : '请设置CopyCat服务信息'}
db.execute('SELECT URL,IS_ARCHIVED FROM URLS WHERE ID=%s',bid)
v = db.getone()
if not v:
return {'error': 'access deny'}
url,flag = v
if int(flag) in [1,2]: #已经提交了的或者正准备真实提交的
return {'ok': 1}
db.execute('UPDATE URLS SET IS_ARCHIVED=2 WHERE ID=%s',bid)
db.commit()
return {'ok': 1}
def apiheart(db):
"""
喜爱/取消喜爱
"""
bb = []
try:
flag = int(request.POST.get('flag','0'))
if flag not in [0,1]:
return {'error':'参数错误'}
bids = request.POST.get('bookmarkids','').split(',')
if len(bids) < 1:
return {'error':'参数错误'}
for b in bids:
bid = int(b)
if bid < 1: return {'error':'参数错误'}
bb.append(bid)
except:
return {'error':'参数错误'}
for bid in bb:
db.execute('UPDATE URLS SET IS_HEART =%s WHERE ID=%s',(flag,bid))
db.commit()
return {'ok':1}
def template_strings_getset():
key = request.POST.get('key', '').strip()
value = request.POST.get('value', '').strip()
getset = r.getset(key,value)
return dictWithAddedCommonFields(key=key, value=value, returned_value=getset)
def confirm():
global alarm_time, alarm_on
# Get the time entered in the time form
alarm_time = request.POST.get('alarm_time', '')
alarm_on = True
# Go to the conformation page
return template('setconfirmation.tpl', t=alarm_time)
print 'obsDatasetId', obsDatasetId
obsParameterId = int(request.POST.get('obsParameterId', '').strip())
print 'obsParameterId', obsParameterId
#reformat DateTime after pulling it out of the POST
POSTstartTime = str(request.POST.get('startTime', '').strip())
startTime = datetime.datetime.fromtimestamp(time.mktime(time.strptime(POSTstartTime, time_format_new)))
print 'startTime', startTime
#reformat DateTime after pulling it out of the POST
POSTendTime = str(request.POST.get('endTime', '').strip())
endTime = datetime.datetime.fromtimestamp(time.mktime(time.strptime(POSTendTime, time_format_new)))
print 'endTime', endTime
latMin = float(request.POST.get('latMin', '').strip())
print 'latMin', latMin
latMax = float(request.POST.get('latMax', '').strip())
print 'latMax', latMax
lonMin = float(request.POST.get('lonMin', '').strip())
print 'lonMin', lonMin
lonMax = float(request.POST.get('lonMax', '').strip())
print 'lonMax', lonMax
filelist = [request.POST.get('filelist', '').strip()]
print 'filelist', filelist[0]
modelVarName = str(request.POST.get('modelVarName', '').strip())
print 'modelVarName', modelVarName
precipFlag = request.POST.get('precipFlag', '').strip()
print 'precipFlag', precipFlag
modelTimeVarName = str(request.POST.get('modelTimeVarName', '').strip())
print 'modelTimeVarName', modelTimeVarName
modelLatVarName = str(request.POST.get('modelLatVarName', '').strip())
def template_hashes_getall():
key = request.POST.get('key', '').strip()
hgetall = r.hgetall(key)
return dictWithAddedCommonFields(key=key, returned_value=hgetall)
def post_get(name, default=''):
return bottle.request.POST.get(name, default).strip()
def login():
username = request.POST.get('user', '')
password = request.POST.get('password', '')
_redirect = request.POST.get('redirect', '/')
print(_redirect)
aaa.login(
username,
password,
success_redirect=_redirect,
fail_redirect='/truc')
def newdir_post(dirpath='NONE'):
# Get login and session
logged_in,session = check_logged_in()
if not logged_in:
redirect('/_login/') # Shouldn't get here w/o being logged in but just in case
elif session.get('name','') not in NBCONFIG.edit_users:
abort(401)
dirpath = utils.join('/',request.POST.get('newdir',''))
systempath = os.path.normpath(utils.join(NBCONFIG.source,dirpath[1:]))
rel = os.path.relpath(systempath,NBCONFIG.source)
if '..' in rel:
abort(403)
try:
os.makedirs(systempath)
except OSError:
pass
# We also want to make an index page in case one doesn't exist.
# This is so that the empty directory shows
if get_systemname(utils.join(dirpath,'index')) is None:
with open(utils.join(systempath,'index'+NBCONFIG.extensions[0]),'w',encoding='utf8') as F:
F.write(u'')