Пример #1
0
def finish():
    cid = request.cookies.get(app.session_cookie_name)
    if cid is None:
        return view("bteditor/index.html", msg='时间久远,没有东西可下,快去编辑种子吧')

    cid = str(cid)
    _dict = kv.get(cid)

    if _dict is None:
        return view("bteditor/index.html", msg="时间久远,没有东西可下,快去编辑种子吧")

    return view("bteditor/finish.html")
Пример #2
0
def finish():
    cid = request.cookies.get(app.session_cookie_name)
    if cid is None:
        return view("bteditor/index.html",msg='时间久远,没有东西可下,快去编辑种子吧')
    
    cid=str(cid)
    _dict=kv.get(cid)
    
    if _dict is None:
        return view("bteditor/index.html",msg="时间久远,没有东西可下,快去编辑种子吧")
    
    return view("bteditor/finish.html")
Пример #3
0
def download():
    cid = request.cookies.get(app.session_cookie_name)
    if cid is None:
        return view("bteditor/index.html")
    
    cid=str(cid)

    _dict=kv.get(cid)
    
    if _dict is None:
        return view("bteditor/index.html",msg="时间久远,没有东西可下,快去编辑种子吧")
    
    response = make_response(bencode.bencode(_dict))
    response.headers["Content-Disposition"] = "attachment; filename="+cid+".torrent"
    kv.delete(cid)
    return response
Пример #4
0
def edit():
    rs = {}
    files=[]
    rs['files']=files
    try:
        if request.content_length > 300*1024:
            return view("bteditor/index.html",msg="文件太大,不要超过300kb!")
        
        _file= request.files['torrent']
        _filename=_file.filename;
        if(_filename.endswith('.torrent')==False):
            return view("bteditor/index.html",msg="上传的文件不对!请重新上传!")
            
        
        _dict = bencode.bdecode(_file.read())
        info = _dict.get('info')
        
        info.pop('publisher.utf-8',None)
        info.pop('name.utf-8',None)
        info.pop('publisher-url.utf-8',None)

        i=1
        for k in info.keys():
            import pdb
            if k == 'files' or k =='name':
                if k== 'name':
                    rs['name']=info[k]
                else:
                    for _file in info[k]:
                        #pdb.set_trace()
                        #if _file['path'] == None or _file['path'][0].strip() == '':
                        #    continue 
                        _file['id'] = i
                        #if _file['path'][0].startswith('_____padding_file') == False:
                        files.append(_file)
                        i+=1
        cid = random_str(16)
        kv.set(cid,_dict,app.permanent_session_lifetime.total_seconds())
        
        _view = view("bteditor/edit.html",p = rs)
        res = make_response( _view )
        res.set_cookie(app.session_cookie_name,cid)
        return res
    except ValueError:
        #return view("bteditor/index.html",err=ValueError)
        raise ValueError
Пример #5
0
def blog_topic(id=1,title=''):
    article = Article.query.get(id)
    if(article==None):
        abort(404)
    content = content = Markup(markdown.markdown(article.content))
    tags = group_tag_with_count()
    categories = group_category_with_count()
    return view("topic.html", **locals())
Пример #6
0
def blog_index(page=1):
    prefix='/'
    suffix=''
    p = Article.query.order_by(Article.add_time.desc()) \
            .paginate(page,PER_PAGE,error_out=False)
    tags = group_tag_with_count()
    categories = group_category_with_count()
    return view('index.html', paginate = p,page=page,tags=tags,categories=categories)
Пример #7
0
def download():
    cid = request.cookies.get(app.session_cookie_name)
    if cid is None:
        return view("bteditor/index.html")

    cid = str(cid)

    _dict = kv.get(cid)

    if _dict is None:
        return view("bteditor/index.html", msg="时间久远,没有东西可下,快去编辑种子吧")

    response = make_response(bencode.bencode(_dict))
    response.headers[
        "Content-Disposition"] = "attachment; filename=" + cid + ".torrent"
    kv.delete(cid)
    return response
Пример #8
0
def edit():
    rs = {}
    files = []
    rs['files'] = files
    try:
        if request.content_length > 300 * 1024:
            return view("bteditor/index.html", msg="文件太大,不要超过300kb!")

        _file = request.files['torrent']
        _filename = _file.filename
        if (_filename.endswith('.torrent') == False):
            return view("bteditor/index.html", msg="上传的文件不对!请重新上传!")

        _dict = bencode.bdecode(_file.read())
        info = _dict.get('info')

        info.pop('publisher.utf-8', None)
        info.pop('name.utf-8', None)
        info.pop('publisher-url.utf-8', None)

        i = 1
        for k in info.keys():
            import pdb
            if k == 'files' or k == 'name':
                if k == 'name':
                    rs['name'] = info[k]
                else:
                    for _file in info[k]:
                        #pdb.set_trace()
                        #if _file['path'] == None or _file['path'][0].strip() == '':
                        #    continue
                        _file['id'] = i
                        #if _file['path'][0].startswith('_____padding_file') == False:
                        files.append(_file)
                        i += 1
        cid = random_str(16)
        kv.set(cid, _dict, app.permanent_session_lifetime.total_seconds())

        _view = view("bteditor/edit.html", p=rs)
        res = make_response(_view)
        res.set_cookie(app.session_cookie_name, cid)
        return res
    except ValueError:
        #return view("bteditor/index.html",err=ValueError)
        raise ValueError
Пример #9
0
def fresh():
    _dict = None
    cid = request.cookies.get(app.session_cookie_name)
    if cid is None:
        return view("bteditor/index.html", msg="时间久远,没有东西可下,快去编辑种子吧")

    cid = str(cid)
    _dict = kv.get(cid)

    if _dict is None:
        return view("bteditor/index.html", msg='时间久远,没有东西可下,快去编辑种子吧')

    info = _dict.get('info')

    for k in info.keys():
        if k == 'files' or k == 'name':
            if k == 'name':
                info[k] = str(request.form['name'])
            else:
                for _file in info[k]:
                    if _file['id'] == None:
                        continue
                    if _file.has_key('path.utf-8'):
                        _file.pop('path.utf-8')
                    if request.form.get('f' + str(_file['id'])) is None:
                        _len = len(_file['path'])
                        del _file['path'][0:_len]
                        _file['path'].append(' ')
                        #info['files'].remove(_file)
                        #del _file
                    else:
                        del _file['path'][0:len(_file['path'])]
                        _file['path'] = str(
                            request.form.get('f' +
                                             str(_file['id']))).split('/')
                        _file.pop('id')

    info = kv.get_info()
    kv.set(cid, _dict, app.permanent_session_lifetime.total_seconds())
    return redirect("./finish")
Пример #10
0
def article_modify(id=1):
    c = Article.query.get(id)
#     c.tags = [t.id for t in c.tags]
#     c.categories = [t.id for t in c.categories]
#     form = ArticleForm()
#     form.categories.default=[88,90]
#     form.tags.default=[16,17,18]
    form=ArticleForm(id=c.id,title=c.title,content=c.content,\
                     tags=[t.id for t in c.tags],\
                     categories=str([t.id for t in c.categories][0]))
    form.tags.choices=[(t.id, t.name) for t in Tag.query.order_by('id')]
    form.categories. choices=[(c.id, c.name) for c in Category.query.order_by('id')]
    return view('/admin/article_modify.html',type=EDIT_TYPE,obj=form)
Пример #11
0
def fresh():
    _dict = None
    cid = request.cookies.get(app.session_cookie_name)
    if cid is None:
    	return  view("bteditor/index.html",msg="时间久远,没有东西可下,快去编辑种子吧")
 
    cid=str(cid)
    _dict=kv.get( cid )
    
    if _dict is None:
        return  view("bteditor/index.html",msg='时间久远,没有东西可下,快去编辑种子吧')
    
    info = _dict.get('info')
    
    for k in info.keys():
        if k == 'files' or k =='name':
            if k == 'name':
                info[k]=str(request.form['name'])
            else:
                for _file in info[k]:
                    if _file['id'] == None :
                        continue
                    if _file.has_key('path.utf-8'):
                        _file.pop('path.utf-8')
                    if request.form.get('f'+str(_file['id'])) is None:
                        _len = len(_file['path'])
                        del _file['path'][0:_len]
                        _file['path'].append(' ')
                        #info['files'].remove(_file)
                        #del _file
                    else:
                        del _file['path'][0:len(_file['path'])]
                        _file['path']=str(request.form.get('f'+str(_file['id']))).split('/')
                        _file.pop('id')
    
    info = kv.get_info()
    kv.set(cid,_dict,app.permanent_session_lifetime.total_seconds()) 
    return redirect("./finish")
Пример #12
0
def blog_category(page=1,param=''):
    if(param==''):
        abort(404)
#     import pdb
#     pdb.set_trace()    
    paginate = Article.query.filter(Article.categories.any(name = param)) \
            .order_by(Article.add_time.desc()) \
            .paginate(page,PER_PAGE,error_out=False)
            
    tags = group_tag_with_count()
    categories = group_category_with_count()
    prefix='/category/'
    suffix='/'+param
    return view("index.html", **locals())
Пример #13
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and bcrypt.check_password_hash(user.password,
                                               form.password.data):
            login_user(user, remember=form.remember.data)
            next_page = request.args.get('next')
            flash(f'Welcome {user.username}', 'success')
            return redirect(next_page) if next_page else redirect(
                url_for('home'))
        else:
            flash('Unsuccess login! check email or password', 'danger')
    return view('login.html', title='Login', form=form)
Пример #14
0
def listteams():
    teams = [[]]
    #points = 0
    bracket = "http://fantasy.espn.com/tournament-challenge-bracket/2018/en/entry?entryID=5444662"
    with urllib.request.urlopen(bracket) as response:
        html = response.read()
    mysoup = soup(html, 'html.parser')
    gameid = 0
    for gameid in range(64):
        match = mysoup.find("div", attrs={'data-slotindex': str(gameid)})
        teamid = int(match['data-teamid'][0])
        teamname = match.find('span', attrs={'class': 'name'}).text.strip()
        teamseed = match.find('span', attrs={'class': 'seed'}).text.strip()
        
        teams.append([teamid, teamname, teamseed])
     
    return view('listteams.html', teams=teams)
Пример #15
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashed_password = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=hashed_password)
        db.session.add(user)
        db.session.commit()
        flash(
            f'Account has bean created for {form.username.data}! You Can Login Now ',
            'success')
        return redirect(url_for('login'))
    return view('register.html', title='Register', form=form)
Пример #16
0
def login():
    if current_user.is_authenticated():
        return redirect(url_for('.index'))

    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=form.username.data).first() 
        if user is not None and user.valid_password(form.passwd.data):
            if login_user(user, remember=form.remember.data):
                # Enable session expiration only if user hasn't chosen to be
                # remembered.
                session.permanent = not form.remember.data
                flash('登陆成功!', 'success')
                return redirect(request.args.get('next') or url_for('.index'))
            else:
                flash('账户已禁用!', 'error')
        else:
            flash('用户名或密码错误!', 'error')
    return view("admin/login.html",form=form)
Пример #17
0
def connorbracket():
    teams = [[]]
    #points = 0
    bracket = "http://fantasy.espn.com/tournament-challenge-bracket/2019/en/entry?entryID=27874548"
    with urllib.request.urlopen(bracket) as response:
        html = response.read()
    mysoup = soup(html, 'html.parser')
    gameid = 0
    for gameid in range(126):
        

        match = mysoup.find("div", attrs={'data-slotindex': str(gameid)})
        teamid = int(match['data-teamid'])
        teamname = match.find('span', attrs={'class': 'name'}).text.strip()
        teamseed = match.find('span', attrs={'class': 'seed'}).text.strip()
        pickedstatus = 0
        # pick status-- either:
        # 0      not picked -- game tbd // black
        # 1      picked - game tbd // blue
        # 2      picked incorrectly or out -- //red
        # 3      picked correctly -- // green
        pickedstatus = 0
        if gameid < 64:
            gametags = match.find("span")['class']
            if 'selectedToAdvance' in gametags:
                # picked by user 
                # if not picked by user it will stay equal to 0 and be black
                if 'winner' in gametags:
                    # user was right
                    pickedstatus=3
                elif 'loser' in gametags:
                    # user was wrong
                    pickedstatus=2
                else:
                    # game hasn't been played yet
                    pickedstatus = 1
        teams.append([teamid, teamname, teamseed, pickedstatus])
     
    return view('userbracket.html', teams=teams)
Пример #18
0
def tag_add():
    form = TagForm()
    return view('/admin/tag_modify.html',type=ADD_TYPE,obj=form)
Пример #19
0
def index():
    return view("bteditor/index.html")
Пример #20
0
def help():
    return view("bteditor/help.html")
Пример #21
0
def category_modify(id=1):
    c = Category.query.get(id)
    form = CategoryForm(request.form,c)
    return view('/admin/category_modify.html',type=EDIT_TYPE,obj=form)
Пример #22
0
def bracket():
    return view('bracket.html')
Пример #23
0
def tag(page=1):
    p = Tag.query.order_by(Tag.id.desc()).paginate(page,PER_PAGE,error_out=False)
    return view('admin/tag.html', paginate = p,page=page)
Пример #24
0
def about():
    return view('about.html', title='About')
Пример #25
0
def post_auth(uuid=None):
    # http://identityChain.com/nber/post_auth/uuid=[uuid]
    if uuid in uuidlist:
        return view('/nber/signin.html', name=uuidlist[uuid])
    else:
        return view('/nber/signup.html')
Пример #26
0
def login():
    return view('/nber/login.html')
Пример #27
0
def index(name=None):
    """
    Show an index template
    :return:
    """
    return view('nber/index.html')
Пример #28
0
def category_add():
    form = CategoryForm()
    return view('/admin/category_modify.html',type=ADD_TYPE,obj=form)
Пример #29
0
def tag_modify(id=1):
    c = Tag.query.get(id)
    form = TagForm(request.form,c)
    return view('/admin/tag_modify.html',type=EDIT_TYPE,obj=form)
Пример #30
0
def home():
    return view('home.html', posts=posts)
Пример #31
0
def article_add():
    form = ArticleForm()
    form.tags.choices=[(t.id, t.name) for t in Tag.query.order_by('id')]
    form.categories. choices=[(c.id, c.name) for c in Category.query.order_by('id')]
    return view('/admin/article_modify.html',type=ADD_TYPE,obj=form)
Пример #32
0
def main():
    return view('main.htm'), 200
Пример #33
0
def index():
    return view("bteditor/index.html")
Пример #34
0
def account():
    return view('account.html', title='Account')
Пример #35
0
def article(page=1):
    p = Article.query.order_by(Article.id.desc()).paginate(page,PER_PAGE,error_out=False)
    return view('admin/article.html', paginate = p,page=page)
Пример #36
0
def help():
    return view("bteditor/help.html")
Пример #37
0
def category(page=1):
    p = Category.query.order_by(Category.id_num.desc()).paginate(page,PER_PAGE,error_out=False)
    return view('admin/category.html', paginate = p,page=page)
Пример #38
0
def index():
    """
    Show an index template
    :return:
    """
    return view('index.html')
Пример #39
0
def index():
    """
    Show an index template
    :return:
    """
    return view('docs/home.html')
Пример #40
0
def addnewface():
    """
    Show an index template
    :return:
    """
    return view('identitychain/addnewface.html')
Пример #41
0
from flask import Blueprint, render_template as view

docs = Blueprint('docs',
                 __name__,
                 static_folder='static',
                 template_folder='templates')


@docs.route('/')
def index():
    """
    Show an index template
    :return:
    """


return view('docs/index.html')
Пример #42
0
def blog_categories():
    _endpoint='blog_category'
    items = group_category_with_count()
    return view('tags_and_categories.html',**locals()) 
Пример #43
0
def index():
    """
    Show an index template
    :return:
    """
    return view('identitychain/index.html')