def encodermanage(self): tmpl = env.get_template("encodermanage.html") js = ['/js/odr-encodermanage.js'] return tmpl.render(tab='encodermanage', js=js, is_login=is_login(), is_network=is_network(self.config_file))
def user(self): tmpl = env.get_template("user.html") js = ['/js/odr-user.js'] return tmpl.render(tab='user', js=js, is_login=is_login(), is_network=is_network(self.config_file))
def help(self): tmpl = env.get_template("help.html") js = [] return tmpl.render(tab='help', js=js, is_login=is_login(), is_network=is_network(self.config_file))
def about(self): tmpl = env.get_template("about.html") js = [] return tmpl.render(tab='about', js=js, is_login=is_login(), is_network=is_network(self.config_file))
def backup(self): tmpl = env.get_template("backup.html") js = ['/js/odr-backup.js'] return tmpl.render(tab='backup', js=js, is_login=is_login(), is_network=is_network(self.config_file))
def status(self): tmpl = env.get_template("status.html") js = ['/js/odr-status.js'] return tmpl.render(tab='status', js=js, is_login=is_login(), is_network=is_network(self.config_file))
def config(self): tmpl = env.get_template("config.html") js = ['/js/odr-config.js'] return tmpl.render(tab='config', js=js, is_login=is_login(), is_network=is_network(self.config_file))
def encoderconfig(self): tmpl = env.get_template("encoderconfig.html") js = ['/js/odr-encoderconfig.js'] return tmpl.render(tab='encoderconfig', js=js, is_login=is_login(), is_network=is_network(self.config_file), is_slide_mgnt=is_slide_mgnt(self.config_file), is_adcast=is_adcast(self.config_file))
def index(page): if auth.is_login(): current_user = session.get('current_user') current_user = db.db_session.query( db.User).filter(db.User.u_name == current_user).first() age = db.get_age(current_user.u_id) my_created_bars = db.get_my_bars(current_user.u_id) my_concentrated_bars = db.get_my_concentrated_bars(current_user.u_id) return render_template('index.html', user=current_user, age=age, my_created_bars=my_created_bars, my_concentrated_bars=my_concentrated_bars, current_page=page) return render_template('index.html', user=db.User(), current_page=page)
def run_retrieve_home(self): self.leetcode.is_login = auth.is_login() if not self.leetcode.is_login: self.leetcode.is_login = auth.login() if self.loading_view: self.loading_view.set_text('Loading') self.leetcode.load() if self.leetcode.quizzes and len(self.leetcode.quizzes) > 0: self.retrieve_home_done(self.leetcode.quizzes) else: self.end_loading() toast = Toast('Request fail!', 10, self.current_view, self.loop) toast.show() self.logger.error('get quiz list fail')
def bar_list(topic, page): global select_topic_bars topic_html = topic select_topic_bars = [] if topic == '推荐': select_topic_bars = db.db_session.query(db.Bar).all() else: select_topic_bars = db.db_session.query( db.Bar).filter(db.Bar.b_topic == topic).all() if auth.is_login(): current_user = session.get('current_user') select_users_info = db.db_session.query( db.User).filter(db.User.u_name == current_user).first() select_barRelation_info = db.db_session.query(db.Bar_relation).filter( db.Bar_relation.u_id == select_users_info.u_id).all() list_b_id = [] list_b_topic = [] list_bars_info = [] for barBelation in select_barRelation_info: b_id = barBelation.b_id select_bars_info = db.db_session.query( db.Bar).filter(db.Bar.b_id == b_id).first() list_b_id.append(b_id) list_bars_info.append(select_bars_info) for bar_info in list_bars_info: b_name = bar_info.b_name if b_name not in list_b_topic: list_b_topic.append(b_name) return render_template("bar_list.html", select_user_info=select_users_info, select_barRelation_info=select_barRelation_info, list_b_topic=list_b_topic, topic_html=topic_html, select_topic_bars=select_topic_bars, current_user=current_user, page=page) else: return render_template("bar_list.html", topic_html=topic_html, select_topic_bars=select_topic_bars, page=page)
def timeline(wall_id) : if not is_login(): return redirect(url_for('login')) if wall_id == 0: wall_id = session['user_id'] session['wall_id'] = wall_id session['wall_username'] = get_user(wall_id).username context = { 'posts':get_wall_posts(wall_id,0), 'BS':BS } postList = render_template('post_list.html',context=context) context = { 'post_list':postList } return render_template('timeline.html', context=context)
def list_new_t(page): if auth.is_login(): current_user = session.get('current_user') currentUser = db.db_session.query( db.User).filter(db.User.u_name == current_user).first() bar = db.db_session.query(db.Bar).limit(8).offset((page - 1) * 8).all() age = '' user = db.db_session.query(db.User).limit(9).offset( (page - 1) * 9).all() posts = db.db_session.query(db.Post).limit(9).offset( (page - 1) * 9).all() for i in user: age = db.get_page_counts(i.u_id) return render_template('list_new_t.html', bar=bar, page=page, user=user, age=age, posts=posts, currentUser=currentUser) else: return redirect('/')
def new_comment(): if not auth.is_login(): return jsonify({'status': 'not_login'}) current_user = session.get('current_user') current_user = db.db_session.query( db.User).filter(db.User.u_name == current_user).first() u_id = current_user.u_id data = request.get_json() p_id = data['p_id'] c_content = data['c_content'] f_id = data['f_id'] db.add_comment(u_id, p_id, c_content, f_id) all_comments = db.get_all_comments(p_id) comments = [] for i in all_comments: commit_user = db.get_user_by_id(i.u_id) if i.f_id == 0: comments.append([ i.c_id, i.u_id, i.p_id, i.c_content, i.f_id, commit_user.u_head_img, commit_user.u_nickname, 0, 0 ]) else: f_user = db.get_user_by_f_id(i.f_id) comments.append([ i.c_id, i.u_id, i.p_id, i.c_content, i.f_id, commit_user.u_head_img, commit_user.u_nickname, f_user.u_id, f_user.u_nickname ]) post_obj = db.db_session.query( db.Post).filter(db.Post.p_id == p_id).first() post = [ post_obj.p_id, post_obj.p_title, post_obj.p_content, post_obj.p_create_at, post_obj.p_count_comments, post_obj.b_id, post_obj.u_id ] return jsonify({'comments': comments, 'post': post})
def network(self): tmpl = env.get_template("network.html") js = ['/js/odr-network.js'] return tmpl.render(tab='user', js=js, is_login=is_login(), is_network=is_network(self.config_file))
def follow(): if not is_login(): return redirect(url_for('login')) user = get_user(session['user_id']) return render_template('follow.html', user = user)
yield None def get_published_year(self): return None if __name__ == '__main__': parse = argparse.ArgumentParser(description='Crawl book infomation') parse.add_argument('url', help='url to crawl') parse.add_argument('path', help='path to save book info') parse.add_argument('-p', '--page', help='specific page you want to crawl', type=int, default=1) args = parse.parse_args() colorama.init() requests = requests.Session() requests.cookies = cookielib.LWPCookieJar('cookies') try: requests.cookies.load(ignore_discard=True) except IOError: Logging.error('run auth.py to log in') raise Exception('have not been authenticated') if not is_login(): Logging.error('cookies have expired, please run auth.py again') raise Exception('have not been authenticated') book = Book(args.url, args.page) book.save_to_excel(args.path)
return None if __name__ == '__main__': parse = argparse.ArgumentParser(description='Crawl book infomation') parse.add_argument('url', help='url to crawl') parse.add_argument('path', help='path to save book info') parse.add_argument('-p', '--page', help='specific page you want to crawl', type=int, default=1) args = parse.parse_args() colorama.init() requests = requests.Session() requests.cookies = cookielib.LWPCookieJar('cookies') try: requests.cookies.load(ignore_discard=True) except IOError: Logging.error('run auth.py to log in') raise Exception('have not been authenticated') if not is_login(): Logging.error('cookies have expired, please run auth.py again') raise Exception('have not been authenticated') book = Book(args.url, args.page) book.save_to_excel(args.path)
def bar_index(bar_path, page): chang = len(db.get_all_bars_hot(page_bar=page, topic='推荐')) print('第几页-----------------------------', page) select_bar_info = db.db_session.query( db.Bar).filter(db.Bar.b_path == bar_path).first() b_id = select_bar_info.b_id select_posts_info = db.db_session.query( db.Post).filter(db.Post.b_id == b_id).all() list1 = [] list_sum = [] list_img = [] for i in select_posts_info: a = i.u_id p_id = i.p_id if a in list1: pass else: list1.append(a) count = 0 user = [] user_img = None for k in list1: sum_user = db.db_session.query(db.Post).filter( db.Post.b_id == b_id).filter(db.Post.u_id == k).count() list_sum.append(sum_user) count = max(list_sum) u_id_suoyin = list_sum.index(count) u_id = list1[u_id_suoyin] user = db.get_user_by_id(u_id) print( type(user), '----------------------------------------------------------------------你猜我是啥' ) print('本吧牛人', user.u_name) user_img = db.get_user_by_id(u_id).u_head_img if auth.is_login(): current_user = session.get('current_user') select_user_info = db.db_session.query( db.User).filter(db.User.u_name == current_user).first() u_id = select_user_info.u_id attetion_bar_state = db.db_session.query( db.Bar_relation).filter(db.Bar_relation.b_id == b_id).filter( db.Bar_relation.u_id == u_id).first() return render_template("bar.html", select_bar_info=select_bar_info, attetion_bar_state=attetion_bar_state, select_user_info=select_user_info, max_sum=count, user=user, select_posts_info=select_posts_info, imgs_path=list_img, user_img=user_img, page=page, current_user=current_user, chang=chang) else: select_bar_info = db.db_session.query( db.Bar).filter(db.Bar.b_path == bar_path).first() return render_template("bar.html", select_bar_info=select_bar_info, max_sum=count, user=user, select_posts_info=select_posts_info, user_img=user_img, page=page, chang=chang)