本文整理汇总了Python中werkzeug.utils方法的典型用法代码示例。如果您正苦于以下问题:Python werkzeug.utils方法的具体用法?Python werkzeug.utils怎么用?Python werkzeug.utils使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug
的用法示例。
在下文中一共展示了werkzeug.utils方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import utils [as 别名]
def main():
'''A simple command-line interface for :py:func:`run_simple`.'''
# in contrast to argparse, this works at least under Python < 2.7
import optparse
from werkzeug.utils import import_string
parser = optparse.OptionParser(
usage='Usage: %prog [options] app_module:app_object')
parser.add_option('-b', '--bind', dest='address',
help='The hostname:port the app should listen on.')
parser.add_option('-d', '--debug', dest='use_debugger',
action='store_true', default=False,
help='Use Werkzeug\'s debugger.')
parser.add_option('-r', '--reload', dest='use_reloader',
action='store_true', default=False,
help='Reload Python process if modules change.')
options, args = parser.parse_args()
hostname, port = None, None
if options.address:
address = options.address.split(':')
hostname = address[0]
if len(address) > 1:
port = address[1]
if len(args) != 1:
sys.stdout.write('No application supplied, or too much. See --help\n')
sys.exit(1)
app = import_string(args[0])
run_simple(
hostname=(hostname or '127.0.0.1'), port=int(port or 5000),
application=app, use_reloader=options.use_reloader,
use_debugger=options.use_debugger
)
示例2: web_login
# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import utils [as 别名]
def web_login(self, *args, **kw):
if request.httprequest.method == 'GET':
if request.session.uid and request.params.get('redirect'):
return http.redirect_with_hash(request.params.get('redirect'))
fm = request.params.get('_fm', None)
if not request.session.uid and fm!=None:
fragment = base64.urlsafe_b64decode(fm.encode('utf-8')).decode('utf-8')
if '_ftype=wo' in fragment:
auth_link = self._get_auth_link_wo()
return werkzeug.utils.redirect(auth_link, 303)
response = super(AuthSignupHome, self).web_login(*args, **kw)
from .controllers import QR_DICT
qr_id = str(request.session.get('qr_id', ''))#kw.get('qr_id', False)
if qr_id and (request.params['login_success'] or request.session.uid):
from .controllers import QR_DICT
if qr_id in QR_DICT:
qr = QR_DICT[qr_id]
if 1:#qr['state']=='fail' and qr['openid']:
# 绑定当前登录的用户
if request.session.uid:
user = request.env["res.users"].sudo().search(([('id','=',request.session.uid)]))
else:
user = request.env.user
user.write({
'oauth_provider_id': qr['data']['oauth_provider_id'],
'oauth_uid': qr['data']['user_id'],
})
request.env.cr.commit()
return response
示例3: web_client
# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import utils [as 别名]
def web_client(self, s_action=None, **kw):
res = super(AuthSignupHome, self).web_client(s_action, **kw)
if not request.session.uid:
fm = request.params.get('_fm', None)
if fm!=None:
res = werkzeug.utils.redirect('/web/login?_fm=%s'%fm, 303)
return res
示例4: mail_action_view
# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import utils [as 别名]
def mail_action_view(self, **kwargs):
_logger.info('>>> %s'%request.httprequest.url)
_logger.info('>>>mail_action_view %s'%kwargs)
if not request.session.uid:
# X2Z0eXBlPXdv
return werkzeug.utils.redirect('/web/login?_fm=X2Z0eXBlPXdv&redirect=%s'%werkzeug.url_quote_plus(request.httprequest.url), 303)
res = super(MailControllerExt, self).mail_action_view(**kwargs)
return res
示例5: main
# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import utils [as 别名]
def main():
'''A simple command-line interface for :py:func:`run_simple`.'''
# in contrast to argparse, this works at least under Python < 2.7
import optparse
from werkzeug.utils import import_string
parser = optparse.OptionParser(usage='Usage: %prog [options] app_module:app_object')
parser.add_option('-b', '--bind', dest='address',
help='The hostname:port the app should listen on.')
parser.add_option('-d', '--debug', dest='use_debugger',
action='store_true', default=False,
help='Use Werkzeug\'s debugger.')
parser.add_option('-r', '--reload', dest='use_reloader',
action='store_true', default=False,
help='Reload Python process if modules change.')
options, args = parser.parse_args()
hostname, port = None, None
if options.address:
address = options.address.split(':')
hostname = address[0]
if len(address) > 1:
port = address[1]
if len(args) != 1:
sys.stdout.write('No application supplied, or too much. See --help\n')
sys.exit(1)
app = import_string(args[0])
run_simple(
hostname=(hostname or '127.0.0.1'), port=int(port or 5000),
application=app, use_reloader=options.use_reloader,
use_debugger=options.use_debugger
)
示例6: test_old_imports
# 需要导入模块: import werkzeug [as 别名]
# 或者: from werkzeug import utils [as 别名]
def test_old_imports(self):
from werkzeug.utils import Headers, MultiDict, CombinedMultiDict, \
Headers, EnvironHeaders
from werkzeug.http import Accept, MIMEAccept, CharsetAccept, \
LanguageAccept, ETags, HeaderSet, WWWAuthenticate, \
Authorization