Invenio学习笔记--Base

来源:互联网 发布:java web框架排行 编辑:程序博客网 时间:2024/06/08 11:35

    Invenio.base:

    构建invenio应用

    包装:

    实现Flask应用包装器

    函数url_for()是标准的flask应用,仅仅当协议从http到安全站点https时候改变。然而,当应用使用非标准端口(例:http://example.org:4000https://example:4001),或者不同的URL时候(例:http://www.example.orghttps://secure.example.org),下面的包装器就不需要了。

    配置:

    CFG_SITE_URL:指定安装可见的URL。例如,使用“http://your.site.com”。不要留后面的斜杠。

    CFG_SITE_URL:指定安装安全网页的安全URL,例如登陆和注册可见。不要留后面的斜杠。如果你不想使用安全网址,将该参数设置为空。

    下面的示例显示了如何使HTTP和HTTPS URL 方案看起来相同。

>>> from flask import url_for>>> from invenio.base.factory import create_app>>> app = create_app()>>> app.config['CFG_SITE_URL'] = 'http://localhost:4000'>>> app.config['CFG_SITE_SECURE_URL'] = 'http://localhost:4000'>>> ctx = app.test_request_context()>>> ctx.push()>>> url_for('search.search')'/search'>>> url_for('search.search', _external=True)'http://localhost:4000/search'>>> url_for('search.search', _external=True, _scheme='https')'http://localhost:4000/search'
对于更多关于Flask的信息,请登录FLask的官方文档。