from flask import request, g, jsonify from flask_login import login_required from flask_helper import RenderTemplate from zh_config import db_conf_path from classes.comment import Comment from classes.user import User from web01 import create_blue __author__ = 'ZhouHeng' url_prefix = "/comment" rt = RenderTemplate("comment", url_prefix=url_prefix) comment_view = create_blue('comment_view', url_prefix=url_prefix, auth_required=False) c_comment = Comment(db_conf_path) c_user = User(db_conf_path) @comment_view.route("/", methods=["GET"]) def get_my_project(): resource_id = request.args["resource_id"] items = c_comment.select_comment(resource_id=resource_id) if request.args.get("version", "1") == "2": user_list = map(lambda x: x["owner"], items) if len(user_list) > 0: u_items = c_user.get_multi_nick_name(user_list) else: u_items = [] data = dict(comments=items, users=u_items)
import os import re from functools import wraps from flask import request, jsonify, g from flask_login import login_required from flask_helper import RenderTemplate, support_upload2 from zh_config import db_conf_path, upload_folder, file_prefix_url from classes.music import Music from web01 import create_blue __author__ = 'meisa' url_prefix = "/music" rt = RenderTemplate("music") music_view = create_blue("music", url_prefix=url_prefix, menu_list={"title": u"音乐管理"}, auth_required=False) c_music = Music(db_conf_path) def refer_music_no(f): @wraps(f) def decorated_function(*args, **kwargs): if "Referer" not in request.headers: g.ref_url = "" else: g.ref_url = request.headers["Referer"] find_no = re.findall("music_no=(\\d+)", g.ref_url) if len(find_no) > 0: g.music_no = find_no[0] elif "music_no" in request.args: g.music_no = request.args["music_no"]
import os import base64 from time import time from random import randint from datetime import datetime from flask import request, send_from_directory, g, jsonify from flask_helper import RenderTemplate from web01 import create_blue, upload_folder __author__ = 'ZhouHeng' url_prefix = "/editor" rt = RenderTemplate("UEditor", url_prefix=url_prefix) editor_view = create_blue('editor_view', url_prefix=url_prefix, auth_required=True) upload_data_dirs = {"image": "img", "scrawl": "scrawl"} for key in upload_data_dirs: key_dir = os.path.join(upload_folder, upload_data_dirs[key]) if os.path.isdir(key_dir) is False: os.mkdir(key_dir) @editor_view.route("/") def demo_func(): title = None if "title" in request.args: title = request.args["title"]
import re import string from functools import wraps from flask import request, jsonify, g from flask_login import login_required from flask_helper import RenderTemplate, support_upload2 from zh_config import db_conf_path, upload_folder, file_prefix_url from classes.exam import Exam from web01 import create_blue __author__ = 'meisa' url_prefix = "/exam" rt = RenderTemplate("exam") exam_view = create_blue("exam", url_prefix=url_prefix, auth_required=False, menu_list={"title": u"测试管理"}) c_exam = Exam(db_conf_path) def referer_exam_no(f): @wraps(f) def decorated_function(*args, **kwargs): if "Referer" not in request.headers: g.ref_url = "" g.exam_no = None else: g.ref_url = request.headers["Referer"] find_no = re.findall("exam_no=(\\d+)", g.ref_url) if len(find_no) > 0: g.exam_no = find_no[0] elif "exam_no" in request.args:
import string from functools import wraps from flask import request, jsonify, g from flask_login import login_required from flask_helper import RenderTemplate, support_upload2 from zh_config import db_conf_path, upload_folder, file_prefix_url from classes.video import Video from web01 import create_blue __author__ = 'meisa' url_prefix = "/video" rt = RenderTemplate("video") video_view = create_blue("video", url_prefix=url_prefix, auth_required=False, menu_list={"title": u"音/视频集管理"}) c_video = Video(db_conf_path) type_dict = dict(dongman=u"动漫", yingshi=u"影视", gxshipin=u"国学视频", gxyinpin=u"国学音频", jtshipin=u"家庭视频", jtyinpin=u"家庭音频") format_dict = [[u"视频", "video/mp4"], [u"音频", "audio/mp3"]] type_info = dict(dongman={ "title": u"动漫", "format": "video/mp4", "p_group": ""
# !/usr/bin/env python # coding: utf-8 from flask import jsonify, redirect from flask_helper import RenderTemplate from web01 import create_blue __author__ = 'meisa' rt = RenderTemplate() index_view = create_blue("index", url_prefix="/") @index_view.route("/", methods=["GET"]) def index(): return redirect("/index/") return rt.render("index.html") @index_view.route("/index/", methods=["GET"]) def index2_page(): m_xl = [u"心理科普", u"心理测试", u"心理调适", u"心理咨询", u"心理电台"] m_gx = [u"视频", u"音频"] m_jt = [u"视频", u"音频"] menu = [m_xl, m_gx, m_jt] return rt.render("index2.html") @index_view.route("/menu/", methods=["GET"]) def get_menu_action(): m_xl = {"title": u"心理健康", "sub": [ {"title": u"心理科普", "url": "/article/?version=2&article_type=xlts"},
import os from time import time from flask import request, g, jsonify from flask_login import login_required from flask_helper import RenderTemplate, support_upload2 from zh_config import db_conf_path, file_prefix_url from classes.article import ArticleManager from web01 import create_blue, upload_folder __author__ = 'ZhouHeng' url_prefix = "/article" rt = RenderTemplate("article", url_prefix=url_prefix) article_view = create_blue('article_view', url_prefix=url_prefix, menu_list={"title": u"文章管理"}, auth_required=False) c_article = ArticleManager(db_conf_path) article_dict = dict(xlts=u"心理调适", meiwen=u"美文") @article_view.route("/", methods=["GET"]) @login_required def add_func(): article_no = "" upload_url = url_prefix + "/upload/" url_info = url_prefix + "/info/" page_article = url_prefix + "/?action=article" page_list = url_prefix + "/" type_desc = ""
from time import time from functools import wraps from flask import request, g, jsonify from flask_login import login_required from flask_helper import RenderTemplate, support_upload2 from zh_config import db_conf_path, upload_folder, file_prefix_url from classes.insider import Insider from web01 import create_blue __author__ = 'ZhouHeng' url_prefix = "/insider" rt = RenderTemplate("insider", url_prefix=url_prefix) insider_view = create_blue('insider_view', url_prefix=url_prefix, auth_required=True) c_insider = Insider(db_conf_path) @insider_view.route("/project/", methods=["GET"]) def get_my_project(): items = c_insider.select_my_project(user_no=g.user_no) return jsonify({"status": True, "data": items}) @insider_view.route("/project/", methods=["POST"]) def new_project_action(): project_name = request.json["project_name"] exec_r, data = c_insider.new_project(g.user_no, project_name) if exec_r is True:
import re from time import time from functools import wraps from flask import request, g, jsonify from flask_login import login_required from flask_helper import RenderTemplate, support_upload2 from zh_config import db_conf_path, upload_folder, file_prefix_url from classes.people import People from web01 import create_blue __author__ = 'ZhouHeng' url_prefix = "/people" rt = RenderTemplate("people", url_prefix=url_prefix) people_view = create_blue('people_view', url_prefix=url_prefix, menu_list={"title": u"人员管理"}, auth_required=False) c_people = People(db_conf_path) group_dict = dict( gxedu={"cn": u"国学教育专家"}, jtedu={"cn": u"家庭教育专家"}, doctor={"cn": u"医生"} ) def referer_people_no(f): @wraps(f) def decorated_function(*args, **kwargs): if "Referer" not in request.headers: g.ref_url = "" else: g.ref_url = request.headers["Referer"]
from flask import g, jsonify, session, request, redirect, make_response, send_file, send_from_directory from flask_login import UserMixin, login_user, current_user, logout_user, login_required from flask_helper import RenderTemplate from zh_config import db_conf_path, web_pro, min_program_conf, upload_folder from classes.user import User from classes.wx import MiniProgram from web01 import create_blue, login_manager __author__ = 'meisa' url_prefix = "/user" rt = RenderTemplate("user") c_user = User(db_conf_path=db_conf_path, upload_folder=upload_folder) mp = MiniProgram(conf_path=min_program_conf, section=web_pro) user_view = create_blue("user", url_prefix=url_prefix, auth_required=False, menu_list=[{"index": -2, "url": "/password/", "title": u"密码修改"}, {"index": -1, "url": "/login/", "title": u"退出"}]) class FlaskUser(UserMixin): user_no = "" def get_id(self): return self.user_no @login_manager.user_loader def load_user(user_id): user = FlaskUser() user.user_no = user_id if "role" in session: