當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。