Falcon Core的灵感来源于Django for Falcon API框架。
falcon-core的Python项目详细描述
猎鹰核心
Falcon Core的灵感来源于Django for Falcon API框架。
安装
pip install falcon-core
用户指南
启动项目
falcon-core startproject api
创建项目API和文件夹API
- API/
- api/manage.py
- APY/API/
- apy/api/初始化py
- apy/api/settings.py
- apy/api/routes.py
- apy/api/wsgi.py
falcon-core startproject api .
在“我的位置”文件夹中创建项目API
- 我的位置/管理.py
- 我的位置/api/
- 我的位置/api/\u init.py
- 我的位置/api/settings.py
- 我的位置/api/routes.py
- 我的位置/api/wsgi.py
falcon-core startproject api folder
在文件夹中创建项目API
- 文件夹/manage.py
- 文件夹/api/
- 文件夹/api/\u init.py
- 文件夹/api/settings.py
- 文件夹/api/routes.py
- 文件夹/api/wsgi.py
启动项目应用程序
python manage.py startapp example
在项目目录中创建应用程序
- 示例/u init_uuu.py
- 示例/resources.py
- 示例/routes.py
python manage.py startapp example.example1
在应用程序中创建应用程序
- 示例/example1/\uu init.py
- 示例/example1/resources.py
- 示例/example1/routes.py
python manage.py startapp example2.example3
- 示例2/初始化py
- 示例2/示例3/初始化py
- 示例2/示例3/resources.py
- 示例2/示例3/routes.py
在example.resource.py
中创建资源import falcon from falcon_core.resources import Resource class ExampleResource(Resource): def on_get(self, req, resp, **kwargs): resp.status = falcon.HTTP_OK resp.media = {'key': 'value'}
将资源添加到路由
example.routes.py
from falcon_core.routes import route from example.resources import ExampleResource routes = [ route('/example', ExampleResource()), ]
(1)api.resource.py
from falcon_core.routes import route, include from example.routes import routes as example_routes routes = [ route('', include(example_routes)), ]
(2)api.routes.py
from falcon_core.routes import route, include routes = [ route('', include('example.routes')), ]
添加中间件
在api.settings.py中
... MIDDLEWARE = [ 'module.MiddlewareOrMiddlewareInstance' ] ...
添加路由器转换器
在api.settings.py中
... ROUTER_CONVERTERS = [ 'name': 'module.Converter' ] ...
更改根路径
在api.settings.py中
... ROUTES = 'module.routes' # must have routes list ...