Giter Site home page Giter Site logo

fushall / myblog Goto Github PK

View Code? Open in Web Editor NEW
33.0 2.0 7.0 2.53 MB

基于flask的简单博客系统(a simple blog powered by flask)。

Home Page: http://blog.nmxxy.cn

License: GNU General Public License v3.0

Python 99.99% Batchfile 0.01%
python flask

myblog's Introduction

myblog

这是一个由Flask框架写的极简个人博客,新手友好,代码中的每一个变量名和方法, 都经过了上百次揣摩,非常适合刚入门的新手朋友,可以直接读代码,也可以改一改, 部署到自己的VPS上。预览地址如下:blog.nmxxy.cn

部署环境

Python3.6.5 + Flask 1.0.2 + Centos7 + MariaDB

一键安装myblog所需要的各种库

pip install -r requirements.txt

配置文件的修改

myblog/configs/目录下的除了__init__.py,剩下所有的.py文件都是配置文件。 “configs”是一个python包(package),__init__.py的register_configs方法, 能够自动导入“configs包”下的所有子py模块(就是.py文件)。也就是说,在里面新建 例如“flask_xxxx.py” 文件的时候,不用手动import了。

再说一下子py文件的内容,比如flask_sqlalchemy.py,里面有三个类,分别是 DefalutDevelopmentProduction,其中Default的作用是把 DevelopmentProduction提供的“共同配置项”,集中起来了,不叫“Default” 也行,但是“Development” 和 “Production” 必须有,而且名字不能变。因为 在debug模式下,会把Development类里面的内容当作配置,反之 则是Productionregister_configs的源代码如下:

# 取自configs/__init__.py

def register_configs(app):
    for module in iter_modules(__path__):
        if module.ispkg is False and module.name.startswith('_') is False:
            config_module = import_module(f'{__package__}.{module.name}')
			# 这个地方实现了根据debug模式读取相应配置
            if app.debug:
                config = config_module.Development
            else:
                config = config_module.Production
            app.config.from_object(config)

myblog's People

Contributors

fushall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

myblog's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.