A Web Service Framework Base On Flask And Sqlalchemy
Project description
gt-webcore
Features
- 自动序列化接口返回值为JSON结构;
- 集成了SQLAlchemy、MongoEngine对象映射框架;
- 统一的接口返回值结构;
- 提供简单完善可扩展的接口参数验证机制;
- 完善的异常处理机制;
- 模块化方式加载应用模块,每个应用独立一个蓝图配置;
Install
With pip:
:: pip install gt-webcore
Configration
-
MODULES - 加载模块列表
{ 'name': 'app.resource', 'package': 'resource' }
-
LOGGER_CONFIG - 日志配置字典
日志配置可以参考 python logging 的配置说明; -
SQLAlchemy 配置
具体可以参考 Flask-SQLAlchemy 的配置说明,示例如下:SQLALCHEMY_ENGINE_OPTIONS = { 'pool_recycle': 3600, 'pool_timeout': 15, 'pool_pre_ping': True, 'pool_size': 5 } SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:pwd@host:port/database?charset=utf8'
-
MongoEngine 配置 配置项参考 Flask-MongoEngine 的配置说明,示例如下:
MONGODB_SETTINGS = { 'host': 'localhost', 'port': 27017, 'db': 'demo' }
-
Celery 配置
配置项参考 Celery 配置文档说明,示例如下:CELERY = { 'celery_broker_url': 'redis://guest@localhost:6379', 'result_backend': 'redis://guest@localhost:6379', 'task_routes': { 'app.system.controller.*': {'queue': 'test'} } }
-
Cache 配置 配置项参考 Flask-Caching 的配置说明,示例如下:
CACHE_TYPE = 'RedisCache' CACHE_DEFAULT_TIMEOUT = 300 CACHE_REDIS_URL = 'redis://localhost:6379/2'
Run
from webcore import create_app, release_app
def debug_instance():
from config.develop import DevelopConfig
return create_app(DevelopConfig())
def production_instance():
from config.production import ProductionConfig
return create_app(ProductionConfig())
if __name__ == '__main__':
app = debug_instance()
app.run(host='0.0.0.0', port=5002, debug=True)
release_app()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gt-webcore-0.2.9.tar.gz
(11.9 kB
view details)
Built Distribution
File details
Details for the file gt-webcore-0.2.9.tar.gz
.
File metadata
- Download URL: gt-webcore-0.2.9.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 844ed6c5d408012ef7893d5c8cc9564e54ed2b76a0817ed19ff10e73b317eff7 |
|
MD5 | 584e5af28607099f053bd82296702b9e |
|
BLAKE2b-256 | 772de9f6778f501a38f9562e32aa3a1a626db11df0ac477967641b8b20365129 |
File details
Details for the file gt_webcore-0.2.9-py3-none-any.whl
.
File metadata
- Download URL: gt_webcore-0.2.9-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c436effd6e0dfb62d455a19127b5c06454da339a437d5fe2f1d262acbf2c6cb0 |
|
MD5 | 65c6fe2194fc03ea329a2d3aa7c150e7 |
|
BLAKE2b-256 | a8b3c03db8cf0b649f2317dc8e233c3f4b0f3a548fd772a90026f6c73258a228 |