<commit_before># coding: utf-8
"""
    muxiwebsite: 木犀团队的官网
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    木犀团队是华中师范大学自由的学生互联网团队，分为

        web(前端、后台)，设计， 安卓 组

    木犀官网是木犀团队的官方网站:
    功能模块:

        1.i:   木犀官网   木犀的简介信息
        2.blog:   木犀博客   木犀团队的博客
        3.book:   木犀图书   木犀图书管理
        4.share:  木犀分享   木犀内部的分享小站
        5.profile:  木犀个人页   木犀个人页

    管理模块:
        backend:  木犀统一管理后台

    ~我们在路上，
        前方不会太远~。
"""

from flask import Flask, Markup, redirect, url_for, render_template, request
from flask_sqlalchemy import SQLAlchemy
import flask_login as login
from flask_login import LoginManager
from flask_pagedown import PageDown
from basedir import basedir
import flask_admin as admin
from flask_admin import Admin, BaseView, expose
from flask_admin.contrib.sqla import ModelView
import markdown
import os
import redis 

# the root path of xueer
muxi_root_path = os.path.abspath(os.path.dirname("__filename__"))


# 实例创建＋蓝图注册
app = Flask(__name__)
# 配置(通用)
app.config['SECRET_KEY'] = "I hate flask!"
app.config['KEY_FOR_VERSION'] = "astringhardtoguess"
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['MAX_SEARCH_RESULTS'] = 5  # 图书搜索每页最多加载5个搜索结果
app.config["SHARE_PER_PAGE"] = 5
app.config["MUXI_SHARES_PER_PAGE"] = 10
app.config["SHARE_HOT_PER_PAGE"] = 3
app.config['MUXI_USERS_PER_PAGE'] = 10
app.config['BLOG_PER_PAGE'] = 2
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['UPLOAD_FOLDER']=r'./images/'
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024

# Get from Environment
app.config['SERVER_NAME'] = os.environ.get("MUXI_WEBSITE_SERVERNAME")
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get("MUXI_WEBSITE_SQL") or "sqlite:///" + os.path.join(basedir, 'muxi_data.sqlite')  # 系统相应替换
app.config['SEND_URL']=os.environ.get("ZAODU_URL") or ""

# 初始化扩展(app全局属性)
db = SQLAlchemy(app)
login_manager = LoginManager(app)
login_manager.session_protection = 'strong'
login_manager.login_view = 'auth.login'
pagedown = PageDown(app)

"""qiniu configuration"""
app.config['avatar_ACCESSKEY'] = os.getenv('avatar_AccessKey')
app.config['avatar_SECRETKEY'] = os.getenv('avatar_SecretKey')
app.config['avatar_BUCKETNAME'] = os.getenv('avatar_BucketName')

app.config['apk_ACCESSKEY'] = os.getenv('apk_AccessKey')
app.config['apk_SECRETKEY'] = os.getenv('apk_SecretKey')
app.config['apk_BUCKETNAME'] = os.getenv('apk_BucketName')

"""redis for versions configuration""" 
rds = redis.StrictRedis(host=os.getenv('REDIS1_HOST'),port=6388,db=0)  

# Index
def is_mobie():
    platform = request.user_agent.platform
    if platform in ["android", "iphone", "ipad"]:
        return True
    else:
        return False


class MyAdminIndexView(admin.AdminIndexView):
    """rewrite is_authenticated method"""
    def is_accessible(self):
        # return login.current_user.is_authenticated
        return login.current_user.is_admin()

    def inaccessible_callback(self, name, **kwargs):
        return redirect(url_for('auth.login'))


admin = Admin(
        app,
        name="木muxi犀",
        subdomain = 'auth',
        template_mode="bootstrap3",
        index_view=MyAdminIndexView(),
        base_template='admin/logout.html'
        )


from .models import User, Share, Blog, Book, Comment, Type
admin.add_view(ModelView(User, db.session))
admin.add_view(ModelView(Book, db.session))
admin.add_view(ModelView(Share, db.session))
admin.add_view(ModelView(Comment, db.session))
admin.add_view(ModelView(Blog, db.session))
admin.add_view(ModelView(Type, db.session))


# jinja2 filters
@app.template_filter('neomarkdown')
def neomarkdown(markdown_content):
    """
    jinja2 markdown filter
    :param markdown_content: markdown
    :return: text
    """
    content = Markup(markdown.markdown(markdown_content))
    return content


# 蓝图注册
from .book import books
app.register_blueprint(books)

from .share import shares
app.register_blueprint(shares)

from .auth import auth
app.register_blueprint(auth)

from .blog import blogs
app.register_blueprint(blogs)

from profile import profile
app.register_blueprint(profile)

from i import i
app.register_blueprint(i)

from api import api
app.register_blueprint(api)

def create_app() :
    # 实例创建＋蓝图注册
    app = Flask(__name__)
    # 配置(通用)
    app.config['SECRET_KEY'] = "I hate flask!"
    app.config['KEY_FOR_VERSION'] = "astringhardtoguess"
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
    app.config['MAX_SEARCH_RESULTS'] = 5  # 图书搜索每页最多加载5个搜索结果
    app.config["SHARE_PER_PAGE"] = 5
    app.config["MUXI_SHARES_PER_PAGE"] = 10
    app.config["SHARE_HOT_PER_PAGE"] = 3
    app.config['MUXI_USERS_PER_PAGE'] = 10
    app.config['BLOG_PER_PAGE'] = 10
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    app.config['UPLOAD_FOLDER']=r'./images/'
    app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024

    # Get from Environment
    app.config['SERVER_NAME'] = os.environ.get("MUXI_WEBSITE_SERVERNAME")
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get("MUXI_WEBSITE_SQL") or "sqlite:///" + os.path.join(basedir, 'muxi_data.sqlite')  # 系统相应替换
    app.config['SEND_URL']=os.environ.get("ZAODU_URL") or ""

    # qiniu configuration
    app.config['avatar_ACCESSKEY'] = os.getenv('avatar_AccessKey')
    app.config['avatar_SECRETKEY'] = os.getenv('avatar_SecretKey')
    app.config['avatar_BUCKETNAME'] = os.getenv('avatar_BucketName')

    app.config['apk_ACCESSKEY'] = os.getenv('apk_AccessKey')
    app.config['apk_SECRETKEY'] = os.getenv('apk_SecretKey')
    app.config['apk_BUCKETNAME'] = os.getenv('apk_BucketName')

   # 初始化扩展(app全局属性)
    db.init_app(app)
    login_manager.init_app(app)
    pagedown.init_app(app)

    # 蓝图注册
    from .book import books
    app.register_blueprint(books)

    from .share import shares
    app.register_blueprint(shares)

    from .auth import auth
    app.register_blueprint(auth)

    from .blog import blogs
    app.register_blueprint(blogs)

    from profile import profile
    app.register_blueprint(profile)

    from i import i
    app.register_blueprint(i)

    from api import api
    app.register_blueprint(api)

    return app

<commit_msg>update avatar and apk<commit_after># coding: utf-8
"""
    muxiwebsite: 木犀团队的官网
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    木犀团队是华中师范大学自由的学生互联网团队，分为

        web(前端、后台)，设计， 安卓 组

    木犀官网是木犀团队的官方网站:
    功能模块:

        1.i:   木犀官网   木犀的简介信息
        2.blog:   木犀博客   木犀团队的博客
        3.book:   木犀图书   木犀图书管理
        4.share:  木犀分享   木犀内部的分享小站
        5.profile:  木犀个人页   木犀个人页

    管理模块:
        backend:  木犀统一管理后台

    ~我们在路上，
        前方不会太远~。
"""

from flask import Flask, Markup, redirect, url_for, render_template, request
from flask_sqlalchemy import SQLAlchemy
import flask_login as login
from flask_login import LoginManager
from flask_pagedown import PageDown
from basedir import basedir
import flask_admin as admin
from flask_admin import Admin, BaseView, expose
from flask_admin.contrib.sqla import ModelView
import markdown
import os
import redis

# the root path of xueer
muxi_root_path = os.path.abspath(os.path.dirname("__filename__"))


# 实例创建＋蓝图注册
app = Flask(__name__)
# 配置(通用)
app.config['SECRET_KEY'] = "I hate flask!"
app.config['KEY_FOR_VERSION'] = "astringhardtoguess"
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['MAX_SEARCH_RESULTS'] = 5  # 图书搜索每页最多加载5个搜索结果
app.config["SHARE_PER_PAGE"] = 5
app.config["MUXI_SHARES_PER_PAGE"] = 10
app.config["SHARE_HOT_PER_PAGE"] = 3
app.config['MUXI_USERS_PER_PAGE'] = 10
app.config['BLOG_PER_PAGE'] = 2
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['UPLOAD_FOLDER']=r'./images/'
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024

# Get from Environment
app.config['SERVER_NAME'] = os.environ.get("MUXI_WEBSITE_SERVERNAME")
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get("MUXI_WEBSITE_SQL") or "sqlite:///" + os.path.join(basedir, 'muxi_data.sqlite')  # 系统相应替换
app.config['SEND_URL']=os.environ.get("ZAODU_URL") or ""

# 初始化扩展(app全局属性)
db = SQLAlchemy(app)
login_manager = LoginManager(app)
login_manager.session_protection = 'strong'
login_manager.login_view = 'auth.login'
pagedown = PageDown(app)

"""qiniu configuration"""
app.config['avatar_ACCESSKEY'] = os.getenv('avatar_AccessKey')
app.config['avatar_SECRETKEY'] = os.getenv('avatar_SecretKey')
app.config['avatar_BUCKETNAME'] = os.getenv('avatar_BucketName')


"""redis for versions configuration"""
rds = redis.StrictRedis(host=os.getenv('REDIS1_HOST'),port=6388,db=0)

# Index
def is_mobie():
    platform = request.user_agent.platform
    if platform in ["android", "iphone", "ipad"]:
        return True
    else:
        return False


class MyAdminIndexView(admin.AdminIndexView):
    """rewrite is_authenticated method"""
    def is_accessible(self):
        # return login.current_user.is_authenticated
        return login.current_user.is_admin()

    def inaccessible_callback(self, name, **kwargs):
        return redirect(url_for('auth.login'))


admin = Admin(
        app,
        name="木muxi犀",
        subdomain = 'auth',
        template_mode="bootstrap3",
        index_view=MyAdminIndexView(),
        base_template='admin/logout.html'
        )


from .models import User, Share, Blog, Book, Comment, Type
admin.add_view(ModelView(User, db.session))
admin.add_view(ModelView(Book, db.session))
admin.add_view(ModelView(Share, db.session))
admin.add_view(ModelView(Comment, db.session))
admin.add_view(ModelView(Blog, db.session))
admin.add_view(ModelView(Type, db.session))


# jinja2 filters
@app.template_filter('neomarkdown')
def neomarkdown(markdown_content):
    """
    jinja2 markdown filter
    :param markdown_content: markdown
    :return: text
    """
    content = Markup(markdown.markdown(markdown_content))
    return content


# 蓝图注册
from .book import books
app.register_blueprint(books)

from .share import shares
app.register_blueprint(shares)

from .auth import auth
app.register_blueprint(auth)

from .blog import blogs
app.register_blueprint(blogs)

from profile import profile
app.register_blueprint(profile)

from i import i
app.register_blueprint(i)

from api import api
app.register_blueprint(api)

def create_app() :
    # 实例创建＋蓝图注册
    app = Flask(__name__)
    # 配置(通用)
    app.config['SECRET_KEY'] = "I hate flask!"
    app.config['KEY_FOR_VERSION'] = "astringhardtoguess"
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
    app.config['MAX_SEARCH_RESULTS'] = 5  # 图书搜索每页最多加载5个搜索结果
    app.config["SHARE_PER_PAGE"] = 5
    app.config["MUXI_SHARES_PER_PAGE"] = 10
    app.config["SHARE_HOT_PER_PAGE"] = 3
    app.config['MUXI_USERS_PER_PAGE'] = 10
    app.config['BLOG_PER_PAGE'] = 10
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    app.config['UPLOAD_FOLDER']=r'./images/'
    app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024

    # Get from Environment
    app.config['SERVER_NAME'] = os.environ.get("MUXI_WEBSITE_SERVERNAME")
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get("MUXI_WEBSITE_SQL") or "sqlite:///" + os.path.join(basedir, 'muxi_data.sqlite')  # 系统相应替换
    app.config['SEND_URL']=os.environ.get("ZAODU_URL") or ""

    # qiniu configuration
    app.config['avatar_ACCESSKEY'] = os.getenv('avatar_AccessKey')
    app.config['avatar_SECRETKEY'] = os.getenv('avatar_SecretKey')
    app.config['avatar_BUCKETNAME'] = os.getenv('avatar_BucketName')


   # 初始化扩展(app全局属性)
    db.init_app(app)
    login_manager.init_app(app)
    pagedown.init_app(app)

    # 蓝图注册
    from .book import books
    app.register_blueprint(books)

    from .share import shares
    app.register_blueprint(shares)

    from .auth import auth
    app.register_blueprint(auth)

    from .blog import blogs
    app.register_blueprint(blogs)

    from profile import profile
    app.register_blueprint(profile)

    from i import i
    app.register_blueprint(i)

    from api import api
    app.register_blueprint(api)

    return app


{'fraction_non_alphanumeric': 0.1257383966244726, 'fraction_numerical': 0.009113924050632912, 'mean_word_length': 4.406478102189781, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4002822', 'n_tokens_mistral': 4770, 'n_tokens_neox': 4749, 'n_words': 759}