示例#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
文件: app.py 项目: suhaibkn/py2do
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
文件: views.py 项目: Ogwang/store_api
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')