python类redirect()的实例源码

app.py 文件源码 项目:first_timer_scraper 作者: niccokunzmann 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def add_user(user):
    """Trace back the user's repositories to their origins.

    Submit all found organizations.
    """
    redirect("/organization/" + user)
app.py 文件源码 项目:first_timer_scraper 作者: niccokunzmann 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_user(user, ending):
    """Return the status of this github user.

    - what are the first-timer repositories?
    """
    redirect("/organization/" + user + "." + ending)
app.py 文件源码 项目:first_timer_scraper 作者: niccokunzmann 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_all_users(ending):
    """All the users and their statuses."""
    redirect("/organizations." + ending)
app.py 文件源码 项目:first_timer_scraper 作者: niccokunzmann 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_source_redirect():
    """Get the source code as a zip file."""
    redirect(ZIP_PATH)
service.py 文件源码 项目:ectou-metadata 作者: monetate 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def slashify():
    bottle.redirect(bottle.request.path + "/", 301)
chat.py 文件源码 项目:bottle_beginner 作者: denzow 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def enter():
    """
    ??????????
    ????????cookie??????????????????????

    :return:
    """
    # POST??????
    username = request.POST.get("username")
    print("POST username is ", username)

    # cookie????
    response.set_cookie("username", username)

    return redirect("/chat_room")
app_routes.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def get_load_apps():
    root.load_apps()
    redirect('/myapps')
app_routes.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def removeapp():
    user = root.authorized()
    uid = users(user=user).id
    app = request.forms.app
    appid = apps(name=app).id
    auid = app_user(uid=uid, appid=appid).id
    del app_user[auid]
    print "removing user", user, uid, "access to app", app, appid
    db.commit()
    redirect('/myapps')
account.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def post_login():
    if not config.auth:
        return "ERROR: authorization disabled. Change auth setting in config.py to enable"

    s = request.environ.get('beaker.session')
    row = users(user=request.forms.get('user').lower())
    pw = request.forms.passwd
    err = "<p>Login failed: wrong username or password</p>"
    # if password matches, set the USER_ID_SESSION_KEY
    hashpw = hashlib.sha256(pw).hexdigest()

    try:
        if hashpw == row.passwd:
            # set session key
            s[USER_ID_SESSION_KEY] = row.user.lower()
            s.save()
        else:
            return err
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        print traceback.print_exception(exc_type, exc_value, exc_traceback)
        return err
    # if referred to login from another page redirect to referring page
    referrer = request.forms.referrer
    if referrer: redirect('/'+referrer)
    else: redirect('/myapps')
account.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def logout():
    s = request.environ.get('beaker.session')
    s.delete()
    try:
        return template('logout',  {'oauth_client_id': config.oauth_client_id})
    except:
        redirect('/login')
container.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def create_container(id):
    print "creating container:", id
    cli = docker.Client(base_url=base_url)
    host_port_number = int(request.forms.host_port_number)
    container_port_number = int(request.forms.container_port_number)
    try:
        cli.create_container(image=id, ports=[host_port_number], host_config=cli.create_host_config(port_bindings={host_port_number:container_port_number}))
        alert = "SUCCESS: container created " + id
    except Exception as e:
        alert = "ERROR: failed to start container " + str(e)

    redirect("/docker?alert="+alert)

# don't think we want to have this option
# @dockerMod.route('/docker/remove_image/<id:path>', method='GET')
# def remove_image(id):
#     print "removing image:", id
#     cli = docker.Client(base_url=base_url)
#     try:
#         msg = cli.remove_image(image=id)
#         alert = "SUCCESS: image removed " + id
#     except:
#         alert = "ERROR: unable to remove image " + id + \
#                  " Either has dependent child images, or a container is running." + \
#                  " Remove the container and retry."
#     redirect("/docker?alert="+alert)
container.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def start_container(id):
    print "starting container:", id
    cli = docker.Client(base_url=base_url)
    try:
        cli.start(container=id)
        alert = "SUCCESS: started container " + id
    except:
        alert = "ERROR: failed to start container " + id
    redirect("/docker?alert="+alert)
container.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def stop_container(id):
    cli = docker.Client(base_url=base_url)
    try:
        cli.stop(container=id)
        alert = "SUCCESS: stopped container " + id
    except:
        alert = "ERROR stopping container " + id
    redirect("/docker?alert="+alert)
container.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def remove_container(id):
    print "removing container:", id
    cli = docker.Client(base_url=base_url)
    try:
        cli.remove_container(id)
        alert = "SUCCESS: removed container " + id
    except:
        alert = "ERROR: problem removing container " + id
    redirect("/docker?alert="+alert)
jobs.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def star_case():
    root.authorized()
    jid = request.forms.jid
    jobs(id=jid).update_record(starred="True")
    db.commit()
    redirect('/jobs')
jobs.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def unstar_case():
    root.authorized()
    jid = request.forms.jid
    jobs(id=jid).update_record(starred="False")
    db.commit()
    redirect('/jobs')
jobs.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def share_case():
    root.authorized()
    jid = request.forms.jid
    jobs(id=jid).update_record(shared="True")
    db.commit()
    # increase count in database for every user
    for u in db().select(users.ALL):
        nmsg = users(user=u.user).new_shared_jobs or 0
        users(user=u.user).update_record(new_shared_jobs=nmsg+1)
    db.commit()
    redirect('/jobs')
jobs.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def unshare_case():
    root.authorized()
    jid = request.forms.jid
    jobs(id=jid).update_record(shared="False")
    db.commit()
    redirect('/jobs')
jobs.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def stop_job():
    root.authorized()
    app = request.forms.app
    cid = request.forms.cid
    jid = request.forms.jid

    if re.search("/", cid):
        return template("error", err="only possible to stop cases that you own")

    root.sched.stop(jid)
    time.sleep(0.1)
    jobs(jid).update_record(state="X")
    db.commit()
    redirect("/case?app="+app+"&cid="+cid+"&jid="+jid)
plots.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def editplotdefs():
    user = root.authorized()
    if user != 'admin':
        return template('error', err="must be admin to edit plots")
    app = request.query.app
    if config.auth and not root.authorized(): redirect('/login')
    if app not in root.myapps: redirect('/apps')
    query = (root.apps.id==plots.appid) & (root.apps.name==app)
    result = db(query).select()
    params = { 'app': app, 'user': user }
    return template('plots/plotdefs', params, rows=result)


问题


面经


文章

微信
公众号

扫码关注公众号