level 1
thstzy
楼主
python属于脚本语言,解释型语言,在python环境中,直接运行py文件就可以看到结果,如果项目直接发布出去,那就是在“裸奔”。所以很有必要对项目代码加密。
先睹为快,看看一个项目采用pymod发布的时候,只有几个文件,
main.py 项目程序入口
setting.py 项目配置
apps 项目模块
plusins 项目插件目录

项目发布目录一览
二、创建项目
创建项目 pymod create demo1
cd demo1
创建模块 pymod add mod1
启动pycharm 开始编写功能模块
一个模块默认由三个文件组成
__init__.py 、 handlers.py 、param_schemas.py
业务逻辑主要在handlers.py中编写
__init__.py
from pymod.blueprint import Blueprintapi = Blueprint("/mod1")from .handlers import *
param_schemas.py
schema_sfz = { "type": "object", "required": ["sfz", "nl"], "properties": { "sfz": { "type": "string", "minLength": 18, "maxLength": 18, "description": "身份证明号码" }, "nl": { "type": "integer", "minimum": 0, "maximum": 150, "description": "年龄" } }}
handlers.py
from . import apifrom pymod.ext import RequestHandler, params_validate,TrueResponse,FalseResponsefrom .param_schemas import schema_sfzfrom pymod.plugins import sfz_check @api.add_route('/hello')class Hello(RequestHandler): def get(self): self.write('Hello World') @params_validate(schema_sfz) def post(self): sfz = self.get_json_arg("sfz") nl =self.get_json_arg("nl") # self.write(TrueResponse(sfz=sfz, nl=nl)) if sfz_check.check_sfzmhm(sfz): self.write(TrueResponse(hint="身份证明号码验证通过")) else: self.write(FalseResponse(hint="身份证明号码验证失败"))
三、项目部署
程序调试 修改setting.py
# 开发模式下 运行的模块名称必须填写
modules = ["mod1"]modules_config ={ "mod1": { "deny_ip": "", "allow_ip": "*" }}
启动程序 python main.py
调试没有问题,进入发布模式
在项目目录下
pymod pack mod1
在target目录下生成mod1.mod文件,将其复制到apps目录中
修改setting.py
# 开发模式下 运行的模块名称必须填写
modules = []
再次运行 python main.py 测试
一切OK,系统就可以发布了。



pymod 使用指南,访问 https://pymod.cn
2021年04月16日 02点04分
1
先睹为快,看看一个项目采用pymod发布的时候,只有几个文件,
main.py 项目程序入口
setting.py 项目配置
apps 项目模块
plusins 项目插件目录

项目发布目录一览二、创建项目
创建项目 pymod create demo1
cd demo1
创建模块 pymod add mod1
启动pycharm 开始编写功能模块
一个模块默认由三个文件组成
__init__.py 、 handlers.py 、param_schemas.py
业务逻辑主要在handlers.py中编写
__init__.py
from pymod.blueprint import Blueprintapi = Blueprint("/mod1")from .handlers import *
param_schemas.py
schema_sfz = { "type": "object", "required": ["sfz", "nl"], "properties": { "sfz": { "type": "string", "minLength": 18, "maxLength": 18, "description": "身份证明号码" }, "nl": { "type": "integer", "minimum": 0, "maximum": 150, "description": "年龄" } }}
handlers.py
from . import apifrom pymod.ext import RequestHandler, params_validate,TrueResponse,FalseResponsefrom .param_schemas import schema_sfzfrom pymod.plugins import sfz_check @api.add_route('/hello')class Hello(RequestHandler): def get(self): self.write('Hello World') @params_validate(schema_sfz) def post(self): sfz = self.get_json_arg("sfz") nl =self.get_json_arg("nl") # self.write(TrueResponse(sfz=sfz, nl=nl)) if sfz_check.check_sfzmhm(sfz): self.write(TrueResponse(hint="身份证明号码验证通过")) else: self.write(FalseResponse(hint="身份证明号码验证失败"))
三、项目部署
程序调试 修改setting.py
# 开发模式下 运行的模块名称必须填写
modules = ["mod1"]modules_config ={ "mod1": { "deny_ip": "", "allow_ip": "*" }}
启动程序 python main.py
调试没有问题,进入发布模式
在项目目录下
pymod pack mod1
在target目录下生成mod1.mod文件,将其复制到apps目录中
修改setting.py
# 开发模式下 运行的模块名称必须填写
modules = []
再次运行 python main.py 测试
一切OK,系统就可以发布了。



pymod 使用指南,访问 https://pymod.cn