本文整理汇总了Python中web.redirect函数的典型用法代码示例。如果您正苦于以下问题:Python redirect函数的具体用法?Python redirect怎么用?Python redirect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了redirect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: POST
def POST(self):
'''
接收指令
:return:
'''
input = web.input(delay=None)
delay = input.delay
if not delay:
return 'failed'
delay = int(delay)
if delay > 0:
username = Common.getLoginUsername() # 获得登录用户名
if not username: # 不存在则返回重定向
return web.redirect('/404')
r, data = ApiManager.getDeviceInfo(username) # 获取设备信息
if r == 'fail': # 获取设备信息失败
if data == errors.NOT_BIND: # 如果未绑定 则进入绑定页
url = '/bind?username=' + username
return web.redirect(url)
else: # 否则进入404
return web.redirect('/404')
else: # 成功获取信息
if delay > 15:
ApiManager.sendOrder(data['id'], orders.REFRESH_RATE_REST) # 发送S_X指令'F_' + str(delay)
else:
ApiManager.sendOrder(data['id'], orders.REFRESH_RATE_HIGH) # 发送S_X指令'F_' + str(delay)
return 'success'
return 'fail'
开发者ID:luodongseu,项目名称:findbake,代码行数:29,代码来源:device.py
示例2: POST
def POST(self):
var = web.input()
if 'fb' in var:
xsrf = util.select_one('xsrf', where='token=$tok', vars={'tok': var.xsrf})
if xsrf is None:
raise status.ApiError('401 Unauthorized')
try:
xsrf = util.select_one('xsrf', where='token=$tok', vars={'tok': var.xsrf})
if xsrf is None:
raise status.ApiError('401 Unauthorized')
user = self.user_auth(var.email, var.pword)
if user is None:
print "this one"
raise status.ApiError('401 Unauthorized')
sess = str(uuid.uuid4())[:64]
values = {
'sess': sess,
'uid': user['id']
}
util.insert('sessions', **values)
web.setcookie('wsid_login', sess, path='/')
except AttributeError as err:
print "that one"
raise status.ApiError('401 Unauthorized (%s)' % err)
web.redirect('/')
开发者ID:AriellaLev,项目名称:whatShouldIDo,代码行数:31,代码来源:main.py
示例3: GET
def GET(self):
url = "http://www.teampura.com/dialog/oauth?"
url += "api_key=" + applify_api_key
url += "&redirect_uri=" + str(urllib.quote("http://" + applify_host_name + "/login",''))
url += "&scope=user,project,items"
web.redirect(url)
开发者ID:albertpadin,项目名称:agile-console,代码行数:7,代码来源:server.py
示例4: POST
def POST(self):
# unlike the usual scheme of things, the POST is actually called
# first here
i = web.input(return_to='/')
if i.get('action') == 'logout':
web.webopenid.logout()
return web.redirect(i.return_to)
i = web.input('openid', return_to='/')
going = owevent.going_to_auth(owglobal.session.datapath,
owglobal.session.host,
i['openid'])
owglobal.server.post_event(going)
output.dbg(str(owglobal.session.host)+\
" is going to "+going.server()+" to authenticate",
self.__class__.__name__)
n = web.webopenid._random_session()
web.webopenid.sessions[n] = {'webpy_return_to': i.return_to}
c = openid.consumer.consumer.Consumer(web.webopenid.sessions[n],
web.webopenid.store)
a = c.begin(i.openid)
f = a.redirectURL(web.ctx.home, web.ctx.home + web.ctx.fullpath)
web.setcookie('openid_session_id', n)
return web.redirect(f)
开发者ID:carriercomm,项目名称:OpenWiFi,代码行数:27,代码来源:webpage.py
示例5: POST
def POST(self):
frm = new_feed_form()
if not frm.validates():
return render.newfeed(frm)
selectors = frm['selector'].value.splitlines()
selectors = [s.strip() for s in selectors]
selectors = filter(None, selectors)
feed = model.find_feed(frm['url'].value, selectors)
if feed:
return web.redirect('/%s' % feed['id'])
res = htmlproc.get_prepared_html(frm['url'].value, selectors)
if 'error' in res:
frm.note = res['error']
return render.newfeed(frm)
# TODO: limit document size
url = res['url']
feed = model.find_feed(url, selectors)
if feed:
return web.redirect('/%s' % feed['id'])
frm['url'].value = url
feed_name = res['title'] or url
if 'do_preview' in web.input():
return render.newfeed(frm, page_preview=res['txt'], feed_name=feed_name)
else:
title = res['title']
feedid = model.create_feed(url=url, name=feed_name, selectors=selectors,
favicon=utils.get_favicon(url), update_interval=DEFAULT_UPDATE_INTERVAL,
content=res['txt'])
return web.redirect('/%s' % feedid)
开发者ID:wladich,项目名称:page2feed,代码行数:30,代码来源:webapp.py
示例6: POST
def POST(self):
if not session.loggedin:
web.redirect("/login?out=1")
else:
user = web.input()
try:
mac_addr = user.mac
if hwaddrp(mac_addr) is False:
mac_addr = '00:00:00:00:00:00'
if not ipaddrp(user.get('ip','')):
raise ValueError
db.update('users', where='id=$user.id',
realname=user.realname,
groups=int(user.grps),
ip=user.ip,
mac=user.mac,
limit_sites=user.limitsites,
channel=int(user.channel),
bw_up=int(user.bw_up),
bw_down=int(user.bw_down),
vars=locals()
)
config_dhcp()
web.redirect("/")
except ValueError:
return self.show(user, True)
开发者ID:Stimels7,项目名称:shaperoute,代码行数:26,代码来源:main.py
示例7: __init__
def __init__(self, isadmin=""):
base_view.__init__(self)
web.header("Content-type", "text/html;UTF-8")
if not self.login_user.logged: # 是否登录
web.seeother("/login/")
elif isadmin == "admin" and not self.login_user.isadmin: # 是否必须是管理员
web.redirect("/error/403")
开发者ID:hellolibo,项目名称:pyblog,代码行数:7,代码来源:views.py
示例8: POST
def POST(self):
auth()
data = web.input(title='', contents='',tag='')
''' update tag '''
for tag in data.tag.split(';'):
db.query('select name from tag')
res = db.fetchAllRows()
if len(tag) == 0:
continue
if (tag,) not in res:
db.insert('insert into tag (name, num) values ("%s",1)'%tag)
else:
db.query('select id,num from tag where name="%s"'%tag)
res = db.fetchOneRow()
print res
db.update('update tag set num=%d where id=%d'%((res[1]+1),res[0]))
''' update article '''
db.query('select * from article where title="%s"'%data.title)
res = db.fetchOneRow()
if res == None:
res = db.insert('insert into article (title, content, tag, posttime) values ("%s", "%s", "%s", "%s")'%(data.title, data.contents, data.tag, time.strftime('%Y-%m-%d %H:%M:%S')))
if not res:
web.redirect('/edit')
return 'success'
return 'repeated title'
开发者ID:yxd123,项目名称:Webpy-blog,代码行数:25,代码来源:views.py
示例9: POST
def POST(self):
you = require_you()
params = web.input(name='')
unique = True
name = params['name']
if name and name != you.get('name',None):
slug = slugify(name)
for row in dbview.users(db, startkey=slug, endkey=slug):
if slug == row.key:
unique = False
break
if unique:
you['name'] = name
you['slug'] = slug
elif not name and 'name' in you:
# blanking your name makes you anonymous, and makes your page inaccessible
del you['name']
del you['slug']
db[you.id] = you
if unique:
web.redirect('/')
else:
return render('settings', errors="Sorry, that name's taken!", you=you)
开发者ID:nickretallack,项目名称:tracker,代码行数:27,代码来源:auth.py
示例10: GET
def GET(self):
db_connect = MySQLdb.connect(host=mysql_host,user=mysql_user,passwd=mysql_pass,db=mysql_db)
db_row = db_connect.cursor()
query = db_row.execute("SELECT * FROM ADMIN")
row = db_row.fetchone()
password_row = row[2]
check_Cookies = web.cookies().get(cookie_name)
if password_row == check_Cookies:
db_connect = MySQLdb.connect(host=mysql_host,user=mysql_user,passwd=mysql_pass,db=mysql_db)
db_row = db_connect.cursor()
query = db_row.execute("SELECT * FROM scans_info ORDER BY scan_id desc")
row = db_row.fetchone()
rowz = list()
while row is not None:
rowz.append(row)
row = db_row.fetchone()
db_connect = MySQLdb.connect(host=mysql_host,user=mysql_user,passwd=mysql_pass,db=mysql_db)
db_row = db_connect.cursor()
query = db_row.execute("SELECT * FROM ADMIN")
user = db_row.fetchone()
session_name = user[1]
return render.reports(rowz,session_name)
else:
url = "/login"
web.redirect(url)
开发者ID:ZeinEddin,项目名称:iScanner,代码行数:25,代码来源:main.py
示例11: POST
def POST(self, node_type):
page = self.page
form = _form_node(node_type,
page.user.roles.keys()) # checks if this node_type exists too
checkaccess(page.user, ''.join(('create ',node_type,' content')))
if form.validates():
node = form.d
node.time_now = int(time.time())
node.uid = page.user.uid
# Get publishing settings.
options = mod[node_type].defaults
# Insert main entry in 'node' table
node.nid = web.insert('node',uid=page.user.uid,created=node.time_now,
changed=node.time_now, title=node.title, type=node_type,
**options)
# Do module specific insertions.
if hasattr(mod[node_type], 'node_insert'):
mod[node_type].node_insert(node)
web.redirect('/node/'+str(node.nid))
content = '<form method="post" name="new_node">'
content += form.render()
content += '<input type="submit" /></form>'
web.render('generic.html')
开发者ID:keizo,项目名称:kulu,代码行数:29,代码来源:node.py
示例12: POST
def POST(self):
""" post the piece """
super(new,self).GET()
from model import piece
from urlparse import urlparse
post = web.input(_method="post",share=[])
if self.cur_user:
# get cur_user
cur_user = self.cur_user
# set user_id
user_id = cur_user["id"]
# set link
if "link" in post:
link = post["link"]
url_parsed = urlparse(link)
if not url_parsed.netloc: #相当于host
link = None
else:
link = None
# set private
private = "private" in post
# set content
content = post["content"]
if content.strip() == "":
error = "内容不能为空"
return render.new(error)
if "pics" in post:
pics = post["pics"]
else:
pics = None
# insert
piece_id = piece.add(user_id=user_id,content=content,link=link,private=private,pics=pics)
# share
if not private:
share = post["share"]
content = sliceContent(content)
share_content = u"「" + content + u"」" + " http://" + web.ctx.host + "/piece/" + str(piece_id)
if "weibo" in share:
client = oauth.createClientWithName("weibo",cur_user)
client.post(share_content)
if "douban" in share:
client = oauth.createClientWithName("douban",cur_user)
client.post(share_content)
# redirect
web.redirect("/people/"+str(user_id))
else:
return render.new()
开发者ID:NoodleJS,项目名称:every-status,代码行数:60,代码来源:new.py
示例13: GET
def GET(self):
""" write new piece """
super(new,self).GET()
if not self.cur_user:
web.redirect("/login")
else:
return render.new()
开发者ID:NoodleJS,项目名称:every-status,代码行数:7,代码来源:new.py
示例14: POST
def POST(self):
color='red'
try:
user=web.input().user
passwd=md5str(web.input().passwd)
if cmp(web.session.Session.yzm.upper(),web.input().yzm.upper()):
f='请输入正确的验证码'
color='red'
return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
else:
pass
if checkpass(user,passwd):
web.session.Session.user=user
web.session.Session.uuid=md5str(user+config.mi_key)
session_add('client_ip','0.0.0.0')
session_add('user_info','')
web.session.Session.user_info=user_persion_info(web.session.Session.user).list()[0]
web.session.Session.client_ip=web.ctx.env.get('REMOTE_ADDR')
n_time=str(nowtime())
login_logs(user,n_time,web.session.Session.client_ip)
session_add('login_time','')
web.session.Session.login_time=n_time
web.redirect('/admin/manager/')
else:
f='验证失败!请输入正确的用户名和密码'
return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
except:
f='验证失败!请开启浏览器的cookies'
return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
开发者ID:freeddser,项目名称:python_scpman,代码行数:34,代码来源:cadmin.py
示例15: GET
def GET(self):
if not session.loggedin:
web.redirect("/login?out=1")
else:
userid = int(web.input().get("id"))
user = db.select('users', where='id=$userid', vars=locals())[0]
return self.show(user, False)
开发者ID:Stimels7,项目名称:shaperoute,代码行数:7,代码来源:main.py
示例16: POST
def POST(self):
user=web.input().user
passwd=md5str(web.input().passwd)
if cmp(web.session.Session.yzm.upper(),web.input().yzm.upper()):
f='Wrong! auth code is wrong!'
color='red'
return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
else:
pass
if checkpass(user,passwd):
web.session.Session.user=user
web.session.Session.uuid=md5str(user+config.mi_key)
session_add('client_ip','0.0.0.0')
session_add('user_info','')
web.session.Session.user_info=user_persion_info(web.session.Session.user).list()[0]
web.session.Session.client_ip=web.ctx.env.get('REMOTE_ADDR')
n_time=str(nowtime())
login_logs(user,n_time,web.session.Session.client_ip)
session_add('login_time','')
web.session.Session.login_time=n_time
web.redirect('/admin/manager/')
else:
f='Fail,username or passwd wrong!'
color='red'
return render.login(f,color,imgs=authidentcode(),b=web.session.Session.yzm)
开发者ID:freeddser,项目名称:python_scpman,代码行数:31,代码来源:cadmin.py
示例17: GET
def GET(self):
'''
声音控制器
静态指令执行
:return:
'''
username = Common.getLoginUsername() # 获得登录用户名
if not username: # 不存在则返回重定向
return web.redirect('/404')
input = web.input(op=None)
op = input.op # 操作码
if op:
r, d = ApiManager.getDeviceInfo(username) # 获取设备信息
if r == 'fail':
if d == errors.NOT_BIND: # 设备未绑定
url = '/bind?username=' + username
return web.redirect(url)
else:
return web.redirect('/404')
if op == 'open': # 打开声音
ApiManager.sendOrder(d['id'], orders.OPEN_SOUND)
elif op == 'close': # 关闭声音
ApiManager.sendOrder(d['id'], orders.CLOSE_SOUND)
else:
'''指令错误'''
return web.redirect('/404')
r, status, time = ApiManager.getSoundStatus(username)
return config.render.sound(status, time)
开发者ID:luodongseu,项目名称:findbake,代码行数:29,代码来源:sound.py
示例18: POST
def POST(self, req_path):
req_path = cgi.escape(req_path)
inputs = web.input()
action = inputs.get("action")
if action and action not in ("edit", "rename"):
raise web.BadRequest()
content = inputs.get("content")
content = web.utils.safestr(content)
# NOTICE: if req_path == `users/`, fullpath will be `/path/to/users/`,
# parent will be `/path/to/users`.
fullpath = get_page_file_or_dir_fullpath_by_req_path(req_path)
parent = osp.dirname(fullpath)
if not osp.exists(parent):
os.makedirs(parent)
if action == "edit":
if not osp.isdir(fullpath):
web.utils.safewrite(fullpath, content)
else:
idx_dot_md_fullpath = osp.join(fullpath, ".index.md")
web.utils.safewrite(idx_dot_md_fullpath, content)
web.seeother("/%s" % req_path)
elif action == "rename":
new_path = inputs.get("new_path")
if not new_path:
raise web.BadRequest()
old_fullpath = get_page_file_or_dir_fullpath_by_req_path(req_path)
if osp.isfile(old_fullpath):
new_fullpath = get_page_file_or_dir_fullpath_by_req_path(new_path)
elif osp.isdir(old_fullpath):
new_fullpath = osp.join(conf.pages_path, new_path)
else:
raise Exception('unknow path')
if osp.exists(new_fullpath):
err_info = "Warning: The page foobar already exists."
return t_render.rename(req_path, err_info, static_files=DEFAULT_GLOBAL_STATIC_FILES)
parent = osp.dirname(new_fullpath)
if not osp.exists(parent):
os.makedirs(parent)
shutil.move(old_fullpath, new_fullpath)
if osp.isfile(new_fullpath):
web.seeother("/%s" % new_path)
elif osp.isdir(new_fullpath):
web.seeother("/%s/" % new_path)
return
url = osp.join("/", req_path)
web.redirect(url)
开发者ID:rui,项目名称:ZWiki,代码行数:60,代码来源:main.py
示例19: GET
def GET(self,name): #идентификация сессии и идентификация пользователя.
print '2222', 'cdx'
web.header('Content-type', 'text/html; charset=utf-8')
con = sqlite3.connect('overhead.sqlite')
cur = con.cursor()
i = web.input()
if i: #Открыть навую сессию после идентификации пользователя
n = i.name
p = i.passw
sql = u"select * from auth_ko where user=? and passw=?"
cur.execute(sql, (n, p))
r = cur.fetchall()
if r:
rez = r[0][1]
sid = uuid.uuid4().hex
sid = str(sid)
sqlu = u"update auth_ko set sid=? where user=? and passw=?"
cur.execute(sqlu, (sid, n, p))
con.commit
web.setcookie('sid', sid, 3600)
print rez, 'sid=',sid
raise web.redirect('/cdx1') #Начата новая сессия. Переходим на следующий шаг.
else:
return render.index('Логин или пароль неверен! ')
else:
raise web.redirect('/cdn') #Сюда попал, если логин и пароль не введены.
开发者ID:AnatolK,项目名称:python_webdev,代码行数:26,代码来源:app.py
示例20: GET
def GET(self, post_id = None, slug = None):
try:
#Return to canonical if the slug is missing
if post_id and not slug:
post = models.Post.get(post_id)
if post:
return web.redirect('/post/%s/%s' % (post_id, post.slug))
else:
raise web.notfound()
#Gest post
if post_id:
post = models.Post.get_post(post_id)
else:
post = models.Post.get_latest_post()
if post:
#Return to canonical if the slug is truncated
if slug and slug.strip() != post.slug:
return web.redirect('/post/%s/%s' % (post_id, post.slug))
prev_post, next_post = models.Post.get_prev_next(post)
else:
raise web.notfound()
return render_template(render.post(post,
prev_post,
next_post,
utils.ContentDiscoverer(post.link, post.category).get_content_block(),
is_user_admin = users.is_current_user_admin()),
title = post.title,
canonical = "post/%s" % (post.get_path()))
except BadKeyError:
raise web.notfound()
开发者ID:saga,项目名称:buckethandle,代码行数:32,代码来源:main.py
注:本文中的web.redirect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论