當前位置: 首頁>>代碼示例>>Python>>正文


Python request.query方法代碼示例

本文整理匯總了Python中bottle.request.query方法的典型用法代碼示例。如果您正苦於以下問題:Python request.query方法的具體用法?Python request.query怎麽用?Python request.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bottle.request的用法示例。


在下文中一共展示了request.query方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_params

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def get_params():
    url = request.query.get('url')

    archive = request.query.get('archive')

    browser_type = request.query.get('browser', 'chrome')

    if not url:
        raise HTTPError(status=400, body='No url= specified')

    if archive not in theconfig['archives']:
        raise HTTPError(status=400, body='No archive {0}'.format(archive))

    if not url.startswith(('http://', 'https://')):
        url = 'http://' + url

    return browser_type, archive, url 
開發者ID:ikreymer,項目名稱:browsertrix,代碼行數:19,代碼來源:app.py

示例2: get_token

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def get_token():
	# Get JSON Payload
	try:
		payload = json.load(request.body)
		username = payload["username"]
		password = payload["password"]
		pwhash = _get_password_hash(password)
	except:
		response.status = 400
		return dict({"message":"No valid JSON found in post body or mandatory fields missing."})

	user_list = rc.scan_iter("USER:*")
	for user in user_list:
		user_record = json.loads(rc.get(user))
		if user_record["username"] == username and user_record["hash"] == pwhash:
			user_token = _issue_token(user=username, id=user[5:], expiry=token_expiry_seconds)
			if 'raw' in request.query:
				return(user_token)
			else:
				return(dict(token_type="bearer", access_token=user_token))

	response.status = 401
	return(dict(info="could not authorize user"))

# Test Auth Token 
開發者ID:u1i,項目名稱:bambleweeny,代碼行數:27,代碼來源:bambleweeny.py

示例3: index

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def index():
    
    _,images_list = get_samples()

    page = 1
    if 'p' in request.query:
        page = int(request.query['p'])
        
    subm_data = get_all_submissions()

    vars = {
            'url':url, 
            'acronym':acronym, 
            'title':title,
            'images':images_list,
            'method_params':method_params,
            'page':page,
            'subm_data':subm_data,
            'submit_params':submit_params,
            'instructions':instructions,
            'extension':gt_ext
            }
    return template('index',vars) 
開發者ID:clovaai,項目名稱:TedEval,代碼行數:25,代碼來源:web.py

示例4: gt_image

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def gt_image():
    imagesFilePath = os.path.dirname(os.path.abspath(__file__)) + "/gt/gt.zip"
    archive = zipfile.ZipFile(imagesFilePath,'r')
    fileName = request.query['sample']
    ext = fileName.split('.')[-1]
    if ext=="jpg":
        header = "image/jpeg"
    elif ext == "gif":
        header = "image/gif"    
    elif ext == "png":
        header = "image/png"            
    
    data = archive.read(fileName)
    body = data
    headers = dict()
    headers['Content-Type'] = header
    if 'c' in request.query:
        headers['Cache-Control'] = "public, max-age=3600"
    return HTTPResponse(body, **headers) 
開發者ID:clovaai,項目名稱:TedEval,代碼行數:21,代碼來源:web.py

示例5: subm_image

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def subm_image():
    submFilePath = os.path.dirname(os.path.abspath(__file__)) + "/output/subm_" + str(request.query['m'])  + ".zip"
    archive = zipfile.ZipFile(submFilePath,'r')
    fileName = request.query['sample']
    ext = fileName.split('.')[-1]
    if ext=="jpg":
        header = "image/jpeg"
    elif ext == "gif":
        header = "image/gif"    
    elif ext == "png":
        header = "image/png"            
    
    data = archive.read(fileName)
    body = data
    headers = dict()
    headers['Content-Type'] = header
    if 'c' in request.query:
        headers['Cache-Control'] = "public, max-age=3600"
    return HTTPResponse(body, **headers) 
開發者ID:clovaai,項目名稱:TedEval,代碼行數:21,代碼來源:web.py

示例6: db_search

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def db_search(query,type=None):
	if type=="ARTIST":
		results = []
		for a in ARTISTS:
			#if query.lower() in a.lower():
			if simplestr(query) in simplestr(a):
				results.append(a)

	if type=="TRACK":
		results = []
		for t in TRACKS:
			#if query.lower() in t[1].lower():
			if simplestr(query) in simplestr(t[1]):
				results.append(get_track_dict(t))

	return results


####
## Useful functions
####

# makes a string usable for searching (special characters are blanks, accents and stuff replaced with their real part) 
開發者ID:krateng,項目名稱:maloja,代碼行數:25,代碼來源:database.py

示例7: file

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def file():
    print('[bottle] url: /upload')
    

    print('[bottle] query:', request.query.keys())
    print('[bottle] forms:', request.forms.keys())
    print('[bottle] files:', request.files.keys())
    
    files = request.files.getall('file')
    print('[bottle] files:', files)
    
    save_path = "./save_file"
    if not os.path.exists(save_path):
        os.mkdir(save_path)
    
    File(files).start()

    print('[bottle] redirect: /')
    redirect('/')
    # print('after redirect') # never executed 
開發者ID:furas,項目名稱:python-examples,代碼行數:22,代碼來源:main.py

示例8: _authenticate

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def _authenticate():
	# Token can be in query string or AUTH header
	if 'token' in request.query:
		access_token = request.query["token"]
	else:
		bearer = request.environ.get('HTTP_AUTHORIZATION','')
		access_token=bearer[7:]

	# Extract the data from the token
	data = _get_token_data(token=access_token)

	# If there was an error, end here
	if data["error"] != "0":
		return(dict(data))

	# Was the token issued by this cluster?
	if data["cluster_id"] != cluster_id:
		return(dict(data))

	# Is the access token still valid?
	token_timestamp = data["timestamp"]
	current_time = int(time.time())
	delta = current_time - token_timestamp
	if delta > token_expiry_seconds:
		# expired
		data["authenticated"] = "False"
		data["info"] = "Token expired"
	else:
		# valid
		data["authenticated"] = "True"
		data["info"] = "Session expires in " + str(token_expiry_seconds - delta) + " seconds."
		# Set response header: username
		response.headers["B9Y-AUTHENTICATED-USER"] = data["user"]

	return(dict(data)) 
開發者ID:u1i,項目名稱:bambleweeny,代碼行數:37,代碼來源:bambleweeny.py

示例9: _get_elements

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def _get_elements(self):
        query = request.query
        include_data = query.get('include_data', '').lower() == 'true'
        include_props = query.get('include_props', '').lower() == 'true'
        return {
            'elements': {
                eid: self._get_element(eid, include_data=include_data, include_props=include_props)
                for eid in self._registry.elements
            }
        } 
開發者ID:dankilman,項目名稱:awe,代碼行數:12,代碼來源:api.py

示例10: method

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def method():
    
    _,images_list = get_samples()
    
    results = None
    page = 1
    subm_data = {}
    
    if 'm' in request.query:
        id = request.query['m']
        submFilePath = os.path.dirname(os.path.abspath(__file__)) + "/output/results_" + id   + ".zip"

        if os.path.isfile(submFilePath):
            results = zipfile.ZipFile(submFilePath,'r')
            
        if 'p' in request.query:
            page = int(request.query['p'])
        
        subm_data = get_submission(id)
        
        if results is None or subm_data is None:
            redirect('/')
    else:
        redirect('/')

    vars = {
        'url':url, 
        'acronym':acronym, 
        'title':title,
        'images':images_list,
        'method_params':method_params,
        'sample_params':sample_params,
        'results':results,
        'page':page,
        'subm_data':subm_data
    }
    return template('method',vars) 
開發者ID:clovaai,項目名稱:TedEval,代碼行數:39,代碼來源:web.py

示例11: get_sample_info

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def get_sample_info():
    
    methodId = request.query['m']    
    submFilePath = os.path.dirname(os.path.abspath(__file__)) + "/output/results_" + methodId + ".zip"
    archive = zipfile.ZipFile(submFilePath,'r')
    id = get_sample_id_from_num(int(request.query['sample']))
    results = json.loads(archive.read(id + ".json"))
    return json.dumps(results) 
開發者ID:clovaai,項目名稱:TedEval,代碼行數:10,代碼來源:web.py

示例12: image_thumb

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def image_thumb():

    sample = int(request.query['sample'])
    fileName,data = get_sample_from_num(sample)
    ext = fileName.split('.')[-1]
    
    f = BytesIO(data)	
    image = Image.open(f)

    maxsize = (205, 130)
    image.thumbnail(maxsize)
    output = BytesIO()
	
    if ext=="jpg":
            im_format = "JPEG"
            header = "image/jpeg"
            image.save(output,im_format, quality=80, optimize=True, progressive=True)
    elif ext == "gif":
            im_format = "GIF"
            header = "image/gif"
            image.save(output,im_format)
    elif ext == "png":
            im_format = "PNG"
            header = "image/png"
            image.save(output,im_format, optimize=True)
    
    contents = output.getvalue()
    output.close()
    
    body = contents
    headers = dict()
    headers['Content-Type'] = header
    if 'c' in request.query:
        headers['Cache-Control'] = "public, max-age=3600"
    
    return HTTPResponse(body, **headers) 
開發者ID:clovaai,項目名稱:TedEval,代碼行數:38,代碼來源:web.py

示例13: gt_file

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def gt_file():
    imagesFilePath = os.path.dirname(os.path.abspath(__file__)) + "/gt/gt.zip"
    archive = zipfile.ZipFile(imagesFilePath,'r')
    fileName = request.query['sample']
    ext = fileName.split('.')[-1]
    if ext=="xml":
        header = "text/xml"

    data = archive.read(fileName)
    body = data
    headers = dict()
    headers['Content-Type'] = header
    if 'c' in request.query:
        headers['Cache-Control'] = "public, max-age=3600"
    return HTTPResponse(body, **headers) 
開發者ID:clovaai,項目名稱:TedEval,代碼行數:17,代碼來源:web.py

示例14: gt_video

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def gt_video():
    imagesFilePath = os.path.dirname(os.path.abspath(__file__)) + "/gt/images.zip"
    archive = zipfile.ZipFile(imagesFilePath,'r')
    fileName = request.query['sample']
    ext = fileName.split('.')[-1]
    header = "video/mp4"

    data = archive.read(fileName)
    body = data
    headers = dict()
    headers['Content-Type'] = header
    if 'c' in request.query:
        headers['Cache-Control'] = "public, max-age=3600"
    return HTTPResponse(body, **headers) 
開發者ID:clovaai,項目名稱:TedEval,代碼行數:16,代碼來源:web.py

示例15: subm_xml

# 需要導入模塊: from bottle import request [as 別名]
# 或者: from bottle.request import query [as 別名]
def subm_xml():
    submFilePath = os.path.dirname(os.path.abspath(__file__)) + "/output/subm_" + str(request.query['m'])  + ".zip"
    archive = zipfile.ZipFile(submFilePath,'r')
    fileName = request.query['sample']
    header = "text/xml"
    data = archive.read(fileName)
    body = data
    headers = dict()
    headers['Content-Type'] = header
    if 'c' in request.query:
        headers['Cache-Control'] = "public, max-age=3600"
    return HTTPResponse(body, **headers) 
開發者ID:clovaai,項目名稱:TedEval,代碼行數:14,代碼來源:web.py


注:本文中的bottle.request.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。