How to use the bottle.request.query.get function in bottle

To help you get started, we’ve selected a few bottle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sahildua2305 / expand-url / bottle / test2.py View on Github external
def expand(url = ""):
    url = request.query.get('url', '')
    if url == "":
        return {"success" : False,
            "start_url" : url,
            "final_url" : "",
            "url_list" : []
            }
    url_list = expandURL(url)
    return {"success" : True,
            "start_url" : url,
            "final_url" : url_list[-1],
            "url_list" : url_list
            }
github IIIF / presentation-validator / iiif-presentation-validator.py View on Github external
def do_GET_test(self):
        """Implement GET request to test url at version."""
        url = request.query.get('url', '')
        version = request.query.get('version', self.default_version)
        url = url.strip()
        parsed_url = urlparse(url)
        if (parsed_url.scheme != 'http' and parsed_url.scheme != 'https'):
            return self.return_json({'okay': 0, 'error': 'URLs must use HTTP or HTTPS', 'url': url})

        try:
            (data, webhandle) = self.fetch(url)
        except Exception as error:
            return self.return_json({'okay': 0, 'error': 'Cannot fetch url. Got "{}"'.format(error), 'url': url})

        # First check HTTP level
        ct = webhandle.headers.get('content-type', '')
        cors = webhandle.headers.get('access-control-allow-origin', '')

        warnings = []
github OpenSooq / Diglett / main.py View on Github external
def update():
	project_name = request.query.get('project')
	update = int(request.query.get('update'))
	if None in [project_name,update] : return HTTPResponse(status=400,body=dumps({'error' : 'invalid request'}))
	if not update:
		crontab_file = common.create_crontab(project=project_name,manager_url=config.get('manager','manager_url'),enabled=True)
		return open(crontab_file,'r').read()
	else:
		db_projects = common.mongo_connect('projects')
		project_info = db_projects.find_one({'name' : project_name},{'hosts' : 1,'active_host' : 1, 'user' : 1})
		try : project_info['hosts']
		except Exception as e :
			logger.error(' requested project does not exist in db : %r',e)
			return HTTPResponse(status=400,body=dumps({'error' : 'this project is not in database'}))
		failed_host = {}; failed_count=0;
		for host in project_info['hosts']:
			ipaddr = host.split(':')[0]
			port = host.split(':')[1]
github Jwink3101 / NBweb / NBweb / main.py View on Github external
### Directory
        # is there a page for this
        indexrootname = utils.join(parts.rootdirname,'index')
        cursor = db.cursor()
        indexpage = cursor.execute("""\
                SELECT * from file_db WHERE rootname LIKE ? """,
                (indexrootname[:-1] + '%',)
            ).fetchall()
        html0 = ''
        if len(indexpage) == 1:
            html0 = indexpage[0]['html'] + '\n\n'

        item = dict()

        if request.query.get('empty',default=None) is not None:
            show_empty = request.query.get('empty',default='false').lower() == 'true'
        else:
            show_empty = NBCONFIG.show_empty
        item['html'] = html0 + dir_listings(parts.rootdirname,db,show_empty=show_empty,drafts=is_edit_user)
        item['rootbasename'] = parts.rootdirname
        if not item['rootbasename'].endswith('/'):
            item['rootbasename'] += '/'
        item['rootname'] = item['rootbasename'] 
        item['meta_title'] = os.path.split(parts.rootdirname)[-1]

        db.close()
        return fill_template(item,show_path=True,isdir=True)
    else:
        refresh = float( request.query.get('refresh',default=-1) )
        
        force = request.query.get('forcereload','false').lower() == 'true'
        item = parse_path(systemname,db,force=force)
github pklaus / brother_ql_web / brother_ql_web.py View on Github external
def get_preview_image():
    context = get_label_context(request)
    im = create_label_im(**context)
    return_format = request.query.get('return_format', 'png')
    if return_format == 'base64':
        import base64
        response.set_header('Content-type', 'text/plain')
        return base64.b64encode(image_to_png_bytes(im))
    else:
        response.set_header('Content-type', 'image/png')
        return image_to_png_bytes(im)
github UDST / urbansim / urbansim / server / urbansimd.py View on Github external
def resp(name):
        limit = int(request.query.get('limit', 10))
        order_by = request.query.get('order_by', None)
        where = request.query.get('query', None)
        ascending = True
        if order_by and order_by[0] == "-":
            order_by = order_by[1:]
            ascending = False
        groupby = request.query.get('groupby', None)
        metric = request.query.get('metric', None)
        page = request.query.get('page', None)
        recs = pandas_statement(
            name, where, order_by, not ascending, groupby, metric, limit, page)
        d = {"recs": [recs.ix[i].values.tolist() for i in recs.index]}
        d["labels"] = recs.columns.tolist()
        return d
    return wrap_request(request, response, resp(name))
github square / connect-api-examples / connect-examples / oauth / python / oauth-flow.py View on Github external
def callback():

  # Extract the returned authorization code from the URL
  authorization_code = request.query.get('code')
  if authorization_code:

    # Provide the code in a request to the Obtain Token endpoint
    oauth_request_body = ObtainTokenRequest()
    oauth_request_body.client_id = application_id
    oauth_request_body.client_secret = application_secret
    oauth_request_body.code = authorization_code
    oauth_request_body.grant_type = 'authorization_code'

    response = oauth_api.obtain_token(oauth_request_body)

    if response.access_token:

      # Here, instead of printing the access token, your application server should store it securely
      # and use it in subsequent requests to the Connect API on behalf of the merchant.
      print ('Access token: ' + response.access_token)
github koniu / recoll-webui / webui.py View on Github external
def get_query():
    query = {
        'query': select([bottle.request.query.get('query'), '']),
        'before': select([bottle.request.query.get('before'), '']),
        'after': select([bottle.request.query.get('after'), '']),
        'dir': select([bottle.request.query.get('dir'), '', ''], [None, '']),
        'sort': select([bottle.request.query.get('sort'), SORTS[0][0]]),
        'ascending': int(select([bottle.request.query.get('ascending'), 0])),
        'page': int(select([bottle.request.query.get('page'), 0])),
    }
    return query
#}}}
github telstra / open-kilda / services / mininet / kilda / mininet / rest.py View on Github external
def _hatchet():
            for _ in pars:
                if request.query.get(_) is None:
                    response.status = 500
                    return "%s: %s must be specified\n" % (request.path, _)
            return __(dict([(_, request.query.get(_)) for _ in pars]))
        return _hatchet
github Jwink3101 / NBweb / NBweb / main.py View on Github external
# Handle if it is a directory
    if not new and systemname.endswith('/'):
        redirect(utils.join('/_edit/',strip_leading(rootpath),'index')) # Do not add extension

    ace = None
    item = {}

    if new:
        if request.query.get('blank','').lower() == 'true':
            filetext = ""
        else:
            filetext = utils.datetime_adjusted(NBCONFIG.time_zone).strftime(NBCONFIG.new_page_txt)
            filetext = filetext.format(numeric_id=get_numeric_id())
        item['title'] = 'New Page'
        newtype = request.query.get('type','file')
        if newtype == 'photo':
            ace = False
    else:
        parts = utils.fileparts(systemname,NBCONFIG.source) # We will *only* use this now
        # Make sure we are allowed to edit this one!
        if parts.ext not in NBCONFIG.extensions:
            #pass # - [ ] Change this if we ever want to allow edit of all
            redirect(utils.join('/',parts.rootname))

        try:
            filetext = utils.filetxt_if_txt(systemname)
        except IOError:
            abort(415)

        filetext = filetext.replace(u'\ufeff', '') # Remove BOM from windows
        item['title'] = 'Editor: ' + parts.rootname