How to use the html.URL function in html

To help you get started, we’ve selected a few html 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 mayank93 / Twitter-Sentiment-Analysis / front-end / web2py / gluon / main.py View on Github external
ajax = x_req_with == 'xmlhttprequest',
                    cid = env.http_web2py_component_element,
                    is_local = env.remote_addr in local_hosts,
                    is_https = env.wsgi_url_scheme \
                        in ['https', 'HTTPS'] or env.https=='on')
                request.uuid = request.compute_uuid() # requires client
                request.url = environ['PATH_INFO']

                # ##################################################
                # access the requested application
                # ##################################################

                if not exists(request.folder):
                    if app == rwthread.routes.default_application \
                            and app != 'welcome':
                        redirect(URL('welcome','default','index'))
                    elif rwthread.routes.error_handler:
                        _handler = rwthread.routes.error_handler
                        redirect(URL(_handler['application'],
                                     _handler['controller'],
                                     _handler['function'],
                                     args=app))
                    else:
                        raise HTTP(404, rwthread.routes.error_message \
                                       % 'invalid request',
                                   web2py_error='invalid application')
                elif not request.is_local and \
                        exists(pjoin(request.folder,'DISABLED')):
                    raise HTTP(503, "<h1>Temporarily down for maintenance</h1>")

                # ##################################################
                # build missing folders
github spiffytech / MobileBlur / gluon / globals.py View on Github external
def requires_https(self):
        """
        If request comes in over HTTP, redirect it to HTTPS
        and secure the session.
        """
        if not global_settings.cronjob and not self.is_https:
            redirect(URL(scheme='https', args=self.args, vars=self.vars))
        
        current.session.secure()
github jniltinho / smb4manager / gluon / globals.py View on Github external
def toolbar(self):
        from html import DIV, SCRIPT, BEAUTIFY, TAG, URL, A
        BUTTON = TAG.button
        admin = URL("admin", "default", "design",
                    args=current.request.application)
        from gluon.dal import DAL
        dbstats = []
        dbtables = {}
        infos = DAL.get_instances()
        for k,v in infos.iteritems():
            dbstats.append(TABLE(*[TR(PRE(row[0]),'%.2fms' %
                                          (row[1]*1000))
                                           for row in v['dbstats']]))
            dbtables[k] = dict(defined=v['dbtables']['defined'] or '[no defined tables]',
                               lazy=v['dbtables']['lazy'] or '[no lazy tables]')
        u = web2py_uuid()
        backtotop = A('Back to top', _href="#totop-%s" % u)
        return DIV(
            BUTTON('design', _onclick="document.location='%s'" % admin),
            BUTTON('request',
github spiffytech / MobileBlur / gluon / sqlhtml.py View on Github external
raise HTTP(400)
            check_authorization()
            response.headers['Content-Type'] = 'text/csv'
            response.headers['Content-Disposition'] = \
                'attachment;filename=rows.csv;'
            raise HTTP(200,str(dbset.select()),
                       **{'Content-Type':'text/csv',
                          'Content-Disposition':'attachment;filename=rows.csv;'})
        elif request.vars.records and not isinstance(
            request.vars.records,list):
            request.vars.records=[request.vars.records]
        elif not request.vars.records:
            request.vars.records=[]

        session['_web2py_grid_referrer_'+formname] = \
            URL(args=request.args,vars=request.vars,
                user_signature=user_signature)
        console = DIV(_class='web2py_console %(header)s %(cornertop)s' % ui)
        error = None
        search_form = None
        if searchable:
            if search_widget=='default':
                search_widget = lambda sfield, url: FORM(
                    SQLFORM.search_menu(sfields),
                    INPUT(_name='keywords',_value=request.vars.keywords,
                          _id='web2py_keywords'),
                    INPUT(_type='submit',_value=T('Search')),
                    INPUT(_type='submit',_value=T('Clear'),
                          _onclick="jQuery('#web2py_keywords').val('');"),
                    _method="GET",_action=url)
            sfields = reduce(lambda a,b:a+b,
                             [[f for f in t if f.readable] for t in tables])
github jyr / MNPP / Library / python26 / lib / python2.6 / site-packages / gluon / main.py View on Github external
# ##################################################
                # compute a request.uuid to be used for tickets and toolbar
                # ##################################################

                response.uuid = request.compute_uuid()

                # ##################################################
                # access the requested application
                # ##################################################

                if not os.path.exists(request.folder):
                    if request.application == rewrite.thread.routes.default_application and request.application != 'welcome':
                        request.application = 'welcome'
                        redirect(Url(r=request))
                    elif rewrite.thread.routes.error_handler:
                        redirect(Url(rewrite.thread.routes.error_handler['application'],
                                     rewrite.thread.routes.error_handler['controller'],
                                     rewrite.thread.routes.error_handler['function'],
                                     args=request.application))
                    else:
                        raise HTTP(404,
                                   rewrite.thread.routes.error_message % 'invalid request',
                                   web2py_error='invalid application')
                request.url = Url(r=request, args=request.args,
                                       extension=request.raw_extension)

                # ##################################################
                # build missing folders
                # ##################################################

                create_missing_app_folders(request)
github jniltinho / smb4manager / gluon / main.py View on Github external
request.env.http_x_forwarded_proto in HTTPS_SCHEMES \
                        or env.https == 'on')
                request.compute_uuid()  # requires client
                request.url = environ['PATH_INFO']

                # ##################################################
                # access the requested application
                # ##################################################

                if not exists(request.folder):
                    if app == rwthread.routes.default_application \
                            and app != 'welcome':
                        redirect(URL('welcome', 'default', 'index'))
                    elif rwthread.routes.error_handler:
                        _handler = rwthread.routes.error_handler
                        redirect(URL(_handler['application'],
                                     _handler['controller'],
                                     _handler['function'],
                                     args=app))
                    else:
                        raise HTTP(404, rwthread.routes.error_message
                                   % 'invalid request',
                                   web2py_error='invalid application')
                elif not request.is_local and \
                        exists(pjoin(request.folder, 'DISABLED')):
                    raise HTTP(503, "<h1>Temporarily down for maintenance</h1>")

                # ##################################################
                # build missing folders
                # ##################################################

                create_missing_app_folders(request)
github spiffytech / MobileBlur / gluon / sqlhtml.py View on Github external
def url(**b):
            b['args'] = args+b.get('args',[])
            b['user_signature'] = user_signature
            return URL(**b)
github web2py / pydal / gluon / sqlhtml.py View on Github external
response.headers['Content-Disposition'] = \
                'attachment;filename='+filename+';'

                    raise HTTP(200, oExp.export(),
                       **{'Content-Type':oExp.content_type,
                          'Content-Disposition':'attachment;filename='+filename+';'})
        #================================================================================

        elif request.vars.records and not isinstance(
            request.vars.records,list):
            request.vars.records=[request.vars.records]
        elif not request.vars.records:
            request.vars.records=[]

        session['_web2py_grid_referrer_'+formname] = \
            URL(args=request.args,vars=request.vars,
                user_signature=user_signature)
        console = DIV(_class='web2py_console %(header)s %(cornertop)s' % ui)
        error = None
        if searchable:
            sfields = reduce(lambda a,b:a+b,
                             [[f for f in t if f.readable] for t in tables])
            if isinstance(search_widget,dict):
                search_widget = search_widget[tablename]
            if search_widget=='default':
                mq,mf,ms = SQLFORM.search_menu(sfields)
                search_widget = lambda sfield, url: FORM(
                    mq,
                    INPUT(_name='keywords',_value=request.vars.keywords,
                          _id='web2py_keywords'),
                    INPUT(_type='submit',_value=T('Search')),
                    INPUT(_type='submit',_value=T('Clear'),
github jniltinho / smb4manager / gluon / globals.py View on Github external
def requires_https(self):
        """
        If request comes in over HTTP, redirect it to HTTPS
        and secure the session.
        """
        cmd_opts = global_settings.cmd_options
        #checking if this is called within the scheduler or within the shell
        #in addition to checking if it's not a cronjob
        if ((cmd_opts and (cmd_opts.shell or cmd_opts.scheduler))
            or global_settings.cronjob or self.is_https):
            current.session.secure()
        else:
            current.session.forget()
            redirect(URL(scheme='https', args=self.args, vars=self.vars))
github uwdata / termite-data-server / web2py / gluon / globals.py View on Github external
def toolbar(self):
        from html import DIV, SCRIPT, BEAUTIFY, TAG, URL, A
        BUTTON = TAG.button
        admin = URL("admin", "default", "design", extension='html',
                    args=current.request.application)
        from gluon.dal import DAL
        dbstats = []
        dbtables = {}
        infos = DAL.get_instances()
        for k,v in infos.iteritems():
            dbstats.append(TABLE(*[TR(PRE(row[0]),'%.2fms' %
                                          (row[1]*1000))
                                           for row in v['dbstats']]))
            dbtables[k] = dict(defined=v['dbtables']['defined'] or '[no defined tables]',
                               lazy=v['dbtables']['lazy'] or '[no lazy tables]')
        u = web2py_uuid()
        backtotop = A('Back to top', _href="#totop-%s" % u)
        # Convert lazy request.vars from property to Storage so they
        # will be displayed in the toolbar.
        request = copy.copy(current.request)