当前位置: 首页>>代码示例>>Python>>正文


Python request.url_root方法代码示例

本文整理汇总了Python中flask.request.url_root方法的典型用法代码示例。如果您正苦于以下问题:Python request.url_root方法的具体用法?Python request.url_root怎么用?Python request.url_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask.request的用法示例。


在下文中一共展示了request.url_root方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def list():
    _dir = get_dir(request.url_root)
    fn = os.path.join(_dir, 'current')
    current = None
    if os.path.exists(fn):
        current = os.readlink(fn)

    ret = ''
    for i in sorted(os.listdir(_dir), reverse=True):
        if not digits_re.match(i):
            continue
        ret = ret + '<a href="diff/%s">%s</a>' % (i, i)
        if i == current:
            ret = ret + " &lt;--"
        ret = ret + '<br/>'
    return ret 
开发者ID:openSUSE,项目名称:openSUSE-release-tools,代码行数:18,代码来源:factory-package-news-web.py

示例2: current

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def current():
    _dir = get_dir(request.url_root)
    fn = os.path.join(_dir, 'current')
    if request.method == 'POST':
        if not 'version' in request.form:
            return "missing version", 400
        version = request.form['version']
        if not digits_re.match(version):
            return "malformed version", 400
        if not os.path.exists(os.path.join(_dir, version)):
            return "invalid version", 400
        tmpfn = os.path.join(_dir, '.' + version)
        app.logger.debug(tmpfn)
        if os.path.exists(tmpfn):
            os.unlink(tmpfn)
        os.symlink(version, tmpfn)
        os.rename(tmpfn, fn)
        return "ok"
    else:
        if not os.path.exists(fn):
            return "", 404
        return os.readlink(fn) 
开发者ID:openSUSE,项目名称:openSUSE-release-tools,代码行数:24,代码来源:factory-package-news-web.py

示例3: placeCall

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def placeCall():
  account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
  api_key = os.environ.get("API_KEY", API_KEY)
  api_key_secret = os.environ.get("API_KEY_SECRET", API_KEY_SECRET)

  client = Client(api_key, api_key_secret, account_sid)
  to = request.values.get("to")
  call = None

  if to is None or len(to) == 0:
    call = client.calls.create(url=request.url_root + 'incoming', to='client:' + IDENTITY, from_=CALLER_ID)
  elif to[0] in "+1234567890" and (len(to) == 1 or to[1:].isdigit()):
    call = client.calls.create(url=request.url_root + 'incoming', to=to, from_=CALLER_NUMBER)
  else:
    call = client.calls.create(url=request.url_root + 'incoming', to='client:' + to, from_=CALLER_ID)
  return str(call) 
开发者ID:twilio,项目名称:voice-quickstart-server-python,代码行数:18,代码来源:server.py

示例4: json

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def json(self):
        unit = [('id', self._id), ('name', self.name),
                ('description', self.description),
                ('expansion', self.expansion),
                ('age', self.age),
                ('created_in',
                '{}structure/{}'.format(request.url_root + request.blueprint,
                                        self.format_name_to_query(self.structure.first().name))
                 if self.structure.first() else self.created_in),
                ('cost', json.loads(self.cost.replace(";", ","))),
                ('build_time', self.build_time),
                ('reload_time', self.reload_time),
                ('attack_delay', self.attack_delay),
                ('movement_rate', self.movement_rate),
                ('line_of_sight', self.line_of_sight),
                ('hit_points', self.hit_points),
                ('range', int(self.range) if self.range.isdigit() else self.range),
                ('attack', self.attack), ('armor', self.armor),
                ('attack_bonus', self.attack_bonus.split(";") if self.attack_bonus else None),
                ('armor_bonus', self.armor_bonus.split(";") if self.armor_bonus else None),
                ('search_radius', self.search_radius),
                ('accuracy', self.accuracy),
                ('blast_radius', self.blast_radius)]
        return OrderedDict([(k, v) for k, v in unit if v]) 
开发者ID:aalises,项目名称:age-of-empires-II-api,代码行数:26,代码来源:unit.py

示例5: json

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def json(self):
        civilization = [('id', self._id),
                        ('name', self.name),
                        ('expansion', self.expansion),
                        ('army_type', self.army_type),
                        ('unique_unit', self.parse_array_field(self.unique_unit)
                         if not self.unit.first()
                         else ['{}unit/{}'.format(request.url_root + request.blueprint,
                                                  self.format_name_to_query(self.unit.first().name))]
                         ),
                        ('unique_tech', self.parse_array_field(self.unique_tech)
                         if not self.technology.first()
                         else ['{}technology/{}'.format(request.url_root + request.blueprint,
                               self.format_name_to_query(self.technology.first().name))]
                         ),
                        ('team_bonus', self.team_bonus),
                        ('civilization_bonus', self.civilization_bonus.split(";"))
                        ]
        return OrderedDict(civilization) 
开发者ID:aalises,项目名称:age-of-empires-II-api,代码行数:21,代码来源:civilization.py

示例6: map_to_resource_url

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def map_to_resource_url(self):
        out = []
        for item in self.applies_to.split(';'):
            unit = get_model('units').query.filter_by(name=item).first()
            structure = get_model('structures').query.filter_by(name=item).first()
            civilization = get_model('civilizations').query.filter_by(name=item).first()

            if unit:
                out.append('{}unit/{}'.format(request.url_root + request.blueprint, self.format_name_to_query(unit.name)))
            elif structure:
                out.append('{}structure/{}'.format(request.url_root + request.blueprint, self.format_name_to_query(structure.name)))
            elif civilization:
                out.append('{}civilization/{}'.format(request.url_root + request.blueprint, self.format_name_to_query(civilization.name)))
            else:
                out.append(item)
        return out 
开发者ID:aalises,项目名称:age-of-empires-II-api,代码行数:18,代码来源:technology.py

示例7: advisory_atom

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def advisory_atom():
    return not_found()

    last_recent_entries = 15
    data = get_advisory_data()['published'][:last_recent_entries]
    # TODO:fix me
    feed = AtomFeed('Arch Linux Security - Recent advisories',
                    feed_url=request.url, url=request.url_root)

    for entry in data:
        advisory = entry['advisory']
        package = entry['package']
        title = '[{}] {}: {}'.format(advisory.id, package.pkgname, advisory.advisory_type)

        feed.add(title=title,
                 content=render_template('feed.html', content=advisory.content),
                 content_type='html',
                 summary=render_template('feed.html', content=advisory.impact),
                 summary_tpe='html',
                 author='Arch Linux Security Team',
                 url=TRACKER_ISSUE_URL.format(advisory.id),
                 published=advisory.created,
                 updated=advisory.created)
    return feed.get_response() 
开发者ID:archlinux,项目名称:arch-security-tracker,代码行数:26,代码来源:advisory.py

示例8: get

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def get(self, hash):
        path = 'static' + os.sep + 'client.zip'
        try:
            os.remove(path)
        except:
            None
        zip = zipfile.ZipFile(path, 'w', zipfile.ZIP_DEFLATED)
        for root, dirs, files in os.walk(CLIENT_FOLDER):
            for f in files:
                zip.write(os.path.join(root, f))
        zip.close()

        client = open(path).read()

        if hash == hashlib.md5(client).hexdigest():
            return {"err": "invalid request"}, 400
        else:
            return {"url": request.url_root + path}, 200 
开发者ID:talos-vulndev,项目名称:FuzzFlow,代码行数:20,代码来源:Update.py

示例9: _feed_json

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def _feed_json():
    posts = []
    for post in post_service.get_published_posts():
        data = dict(author=post.user.username,
                    html=markdown.convert(post.html),
                    url=urljoin(request.url_root,  '/post/' + post.slug),
                    updated=post.updated,
                    published=post.created
                    )
        posts.append(data)

    rss = {
        'sitename': config.sitename(),
        'site': request.url_root,
        'updated': datetime.now(),
        'description': config.description(),
        'posts': posts
    }
    return rss 
开发者ID:whiteclover,项目名称:white,代码行数:21,代码来源:front.py

示例10: get

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def get(self):
        title = SITE['title']
        subtitle = SITE['subtitle']
        feed = AtomFeed(
            '%s' % (title),
            feed_url=request.url,
            url=request.url_root,
            subtitle=subtitle)
        articles = Article.query.limit(10)
        for article in articles:
            feed.add(
                article.title,
                article.to_html(),
                content_type='html',
                author=article.user.username,
                url=urljoin(request.url_root,
                            url_for('blog.article', pk=article.id)),
                updated=article.updated_at,
                published=article.created_at)
        return feed.get_response() 
开发者ID:honmaple,项目名称:maple-blog,代码行数:22,代码来源:router.py

示例11: get_feed

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def get_feed():
    from mhn.common.clio import Clio
    from mhn.auth import current_user
    authfeed = mhn.config['FEED_AUTH_REQUIRED']
    if authfeed and not current_user.is_authenticated():
        abort(404)
    feed = AtomFeed('MHN HpFeeds Report', feed_url=request.url,
                    url=request.url_root)
    sessions = Clio().session.get(options={'limit': 1000})
    for s in sessions:
        feedtext = u'Sensor "{identifier}" '
        feedtext += '{source_ip}:{source_port} on sensorip:{destination_port}.'
        feedtext = feedtext.format(**s.to_dict())
        feed.add('Feed', feedtext, content_type='text',
                 published=s.timestamp, updated=s.timestamp,
                 url=makeurl(url_for('api.get_session', session_id=str(s._id))))
    return feed 
开发者ID:CommunityHoneyNetwork,项目名称:CHN-Server,代码行数:19,代码来源:__init__.py

示例12: save_settings

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def save_settings():
    space_id = request.values.get('spaceId', None)
    delivery_token = request.values.get('deliveryToken', None)
    preview_token = request.values.get('previewToken', None)
    editorial_features = bool(request.values.get('editorialFeatures', False))

    errors = check_errors(space_id, delivery_token, preview_token)

    if not errors:
        update_session_for('space_id', space_id)
        update_session_for('delivery_token', delivery_token)
        update_session_for('preview_token', preview_token)
        update_session_for('editorial_features', editorial_features)

    space = contentful().space(api_id())
    return render_with_globals(
        'settings',
        title=translate('settingsLabel', locale().code),
        errors=errors,
        has_errors=bool(errors),
        success=not bool(errors),
        space=space,
        host=request.url_root
    ), 201 if not errors else 409 
开发者ID:contentful,项目名称:the-example-app.py,代码行数:26,代码来源:settings.py

示例13: reset_settings

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def reset_settings():
    session.pop('space_id', None)
    session.pop('delivery_token', None)
    session.pop('preview_token', None)
    session.pop('editorial_features', None)

    space = contentful().space(api_id())

    return render_with_globals(
        'settings',
        title=translate('settingsLabel', locale().code),
        errors={},
        has_errors=False,
        success=False,
        space=space,
        host=request.url_root
    ) 
开发者ID:contentful,项目名称:the-example-app.py,代码行数:19,代码来源:settings.py

示例14: init_app

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def init_app(self, app, **kwargs):
        self.app = app
        self.manager = APIManager(self.app, **kwargs)

        swagger = Blueprint('swagger', __name__, static_folder='static',
                            static_url_path=self.app.static_url_path + '/swagger', )

        @swagger.route('/swagger')
        def swagger_ui():
            return redirect('/static/swagger/swagger-ui/index.html')

        @swagger.route('/swagger.json')
        def swagger_json():
            # I can only get this from a request context
            self.swagger['host'] = urlparse.urlparse(request.url_root).netloc
            return jsonify(self.swagger)

        app.register_blueprint(swagger) 
开发者ID:mmessmore,项目名称:flask-restless-swagger,代码行数:20,代码来源:__init__.py

示例15: rss_feed

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import url_root [as 别名]
def rss_feed():
    feed = AtomFeed(
        'Patch Server Software Titles',
        feed_url=request.url,
        url=request.url_root,
        generator=('Patch Server', None, __version__))

    titles = SoftwareTitle.query.all()

    for title in titles:
        feed.add(
            title=title.name,
            author=title.publisher,
            content='<b>Version:</b> {} '
                    '<b>| App Name:</b> {} '
                    '<b>| Bundle ID:</b> {}'.format(
                        title.current_version, title.app_name, title.bundle_id),
            url=url_for(
                'patch_by_name_id', name_id=title.id_name, _external=True),
            updated=title.last_modified)

    return feed.get_response() 
开发者ID:brysontyrrell,项目名称:PatchServer,代码行数:24,代码来源:web_ui.py


注:本文中的flask.request.url_root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。