From a58b37b835ad38df8c1ac1891c0b6e9c4dbd201e Mon Sep 17 00:00:00 2001 From: adiao <1819192616@qq.com> Date: Wed, 4 May 2022 19:39:36 +0800 Subject: [PATCH] kuajbang commit --- .idea/.gitignore | 8 ++ .idea/flaskProject2.iml | 21 ++++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ REDME.md | 99 +++++++++++++++++++ app.py | 12 +++ com_kuajbang_api/__init__.py | 0 static/config.py | 66 +++++++++++++ 10 files changed, 230 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/flaskProject2.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 REDME.md create mode 100644 app.py create mode 100644 com_kuajbang_api/__init__.py create mode 100644 static/config.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/flaskProject2.iml b/.idea/flaskProject2.iml new file mode 100644 index 0000000..366ed4f --- /dev/null +++ b/.idea/flaskProject2.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a6fa933 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..66fa42f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/REDME.md b/REDME.md new file mode 100644 index 0000000..1146bae --- /dev/null +++ b/REDME.md @@ -0,0 +1,99 @@ +# 快捷帮项目 + +## 需求: +1、该项目服务于会计行业人员。 + +2、并且提供相应的工作便利和生活便利。 + +## 模块: +1、登录 + +2、用户 + +3、首页 + +4、购物系统 + +5、评论系统 + +6、任务系统 + +7、项目后台管理。 + +## 项目部署: +```bash +#如果是在debian中,安装apt install nginx python3.6以上版本及依赖包、uwsgi、flask、MySQL。 +apt install nginx python3.8 mysql-server[or mariadb] -y +pip3 install flask SQLAlchemy uwsgi +#配置uwsgi + +#进入/home目录下,新建新的用户并配置密码来使用该该项目 +useradd -m kuajbang +passwd kuajbang +#新建服务文件夹存放服务和数据。 +mkdir kuajbang_server/server and kuajbang_server/db +#将新建的用户赋予给该文件,让其后期可以进行服务修改和维护。 +chmod u+wx kuajbang_server +chown kuajbang:kuajbang +#在kuajbang_server/server下新建uwsgi.ini +格式: +[uwsgi] +uid=www-data # Ubuntu系统下默认用户名 +gid=www-data # Ubuntu系统下默认用户组 +project=mysite1 # 项目名 +base = /home/user1 # 项目根目录 + +home = %(base)/Env/%(project) # 设置项目虚拟环境,Docker部署时不需要 +chdir=%(base)/%(project) # 设置工作目录 +module=%(project).wsgi:application # wsgi文件位置 + +master=True # 主进程 +processes=2 # 同时进行的进程数,一般 + +# 以下uwsgi与nginx通信手段3选一即可 +# 选项1, 使用unix socket与nginx通信,仅限于uwsgi和nginx在同一主机上情形 +# Nginx配置中uwsgi_pass应指向同一socket文件 +socket=/run/uwsgi/%(project).sock +# 选项2,使用TCP socket与nginx通信 +# Nginx配置中uwsgi_pass应指向uWSGI服务器IP和端口 +# socket=0.0.0.0:8000 或则 socket=:8000 +# 选项3,使用http协议与nginx通信 +# Nginx配置中proxy_pass应指向uWSGI服务器一IP和端口 +# http=0.0.0.0:8000 +# socket权限设置 +chown-socket=%(uid):www-data +chmod-socket=664 +# 进程文件 +pidfile=/tmp/%(project)-master.pid +# 以后台守护进程运行,并将log日志存于temp文件夹。 +daemonize=/var/log/uwsgi/%(project).log +# 服务停止时,自动移除unix socket和pid文件 +vacuum=True +# 为每个工作进程设置请求数的上限。当处理的请求总数超过这个量,进程回收重启。 +max-requests=5000 +# 当一个请求花费的时间超过这个时间,那么这个请求都会被丢弃。 +harakiri=60 +#当一个请求被harakiri杀掉会输出一条日志 +harakiri-verbose=true +# uWsgi默认的buffersize为4096,如果请求数据超过这个量会报错。这里设置为64k +buffer-size=65536 +# 如果http请求体的大小超过指定的限制,打开http body缓冲,这里为64k +post-buffering=65536 +#开启内存使用情况报告 +memory-report=true +#设置平滑的重启(直到处理完接收到的请求)的长等待时间(秒) +reload-mercy=10 +#设置工作进程使用虚拟内存超过多少MB就回收重启 +reload-on-as=1024 + + +#将服务开启 +uwsgi --ini kuajbang_server/server/uwsgi.ini + +``` + +## 联系: +作者:AiNiSuBing + +链接: +http://github.com/AiNiSuBing/adiao/KuaJBang.git diff --git a/app.py b/app.py new file mode 100644 index 0000000..5d20a01 --- /dev/null +++ b/app.py @@ -0,0 +1,12 @@ +from flask import Flask + +app = Flask(__name__) + + +@app.route('/') +def hello_world(): # put application's code here + return 'Hello World!' + + +if __name__ == '__main__': + app.run() diff --git a/com_kuajbang_api/__init__.py b/com_kuajbang_api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/static/config.py b/static/config.py new file mode 100644 index 0000000..642f9da --- /dev/null +++ b/static/config.py @@ -0,0 +1,66 @@ +import os + + +class Config(object): + """ + 全局配置 + """ + SECRET_KEY = "keuyfasdfa" + SQLALCHEMY_COMMIT_ON_TEARDOWN = True + + @staticmethod + def __init_app(app): + pass + + +class DevelopmentConfig(Config): + """ + 开发环境配置 + """ + DEBUG = True + SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URI') + HOSTNAME = "127.0.0.1" + PORT = "3306" + DATABASE = "kuajbang" + USERNAME = "kuajbang" + PASSWORD = "adiao" + DB_URI = "mysql+mysqldb://{}:{}@{}:{}/{}?charset=utf8".format(USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE) + + +class TestingConfig(Config): + """ + 测试环境配置 + """ + DEBUG = True + SQLALCHEMY_DATABASE_URI = os.environ.get('TESTING_DATABASE_URI') + HOSTNAME = "127.0.0.1" + PORT = "3306" + DATABASE = "kuajbang" + USERNAME = "kuajbang" + PASSWORD = "adiao" + DB_URI = "mysql+mysqldb://{}:{}@{}:{}/{}?charset=utf8".format(USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE) + + +class ProductionConfig(Config): + """ + 生产环境配置 + """ + SQLALCHEMY_DATABASE_URI = os.environ.get('PRODUCTION_DATABASE_URI') + DEBUG = False + HOSTNAME = "127.0.0.1" + PORT = "3306" + DATABASE = "kuajbang" + USERNAME = "kuajbang" + PASSWORD = "adiao" + DB_URI = "mysql+mysqldb://{}:{}@{}:{}/{}?charset=utf8".format(USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE) + + +""" +总环境字典 +""" +config = { + 'development': DevelopmentConfig, + 'testing': TestingConfig, + 'production': ProductionConfig, + 'default': DevelopmentConfig +} \ No newline at end of file