2 Star 3 Fork 2

李沧区天若网络技术工作室 / FlaskMVC

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
dispatch.py 889 Bytes
一键复制 编辑 原始数据 按行查看 历史
mayoushang 提交于 2017-06-14 13:09 . no commit message
# -*- encoding:utf-8 -*-
from main import app
from flask import g, session, request
from flask import render_template
from functools import wraps
import os, sys
import re
def get_module(path, current_module = 'controllers', parent_module = ''):
if parent_module=="" :
module_name = current_module
else:
module_name = '%s.%s' % (parent_module, current_module)
path = os.path.join(path, current_module)
files = os.listdir(path)
files.reverse()
for item in files:
if os.path.isdir(os.path.join(path, item)):
get_module(path, item, module_name)
else:
res = re.match(r'((?!__init__).*)\.py$', item)
if not res:
continue
m = res.group(1)
__import__('%s.%s' % (module_name, m))
@app.errorhandler(404)
def to_404(error):
return '<h2>页面飞走了</h2>'
Python
1
https://gitee.com/bilnn/flaskmvc.git
git@gitee.com:bilnn/flaskmvc.git
bilnn
flaskmvc
FlaskMVC
master

搜索帮助