autoboot web starter
基于 autoboot 框架的插件机制扩展,集成了FastAPI框架,专注于web开发方向。
Quick Start
Install
pip install autoboot-web
Usage
配置
- 启动配置文件
.env
# 环境名称(默认值:dev,框架根据这个配置项来加载当前的环境配置)
ENV_NAME=dev
APPLICATION_NAME=web-runner
- 环境配置文件
.env.dev
APPLICATION_NAME=web-runner-dev
- 主配置文件
autoboot.yaml
autoboot:
application:
name: !env $APPLICATION_NAME
module: api
web:
http:
gzip:
enable: true
# 小于1KB不压缩
minimum_size: 1KB
session:
enable: true
cookie_name: "session_id"
max_age: 120m
security:
cors:
cross_origin: true
# 扫描控制器包
scan_controller_packages:
- controller
创建目录controller
- 在该目录下创建
__init__.py
from .controller import IndexController
__all__=["IndexController"]
- 在该目录创建
index.py
from autoboot_web.mvc.annotation import Controller, Get
@Controller(path="/", tag="index")
class IndexController:
@Get("/")
def index(self, name):
return f"Hello: {name}"
创建并启动容器
- 创建
main.py
from autoboot import AutoBoot, AutoBootConfig
from autoboot_web import WebRunner
context = Autoboot(AutoBootConfig(config_dir="."))
# 注册插件
context.apply(WebRunner())
# 暴露插件的Runner到全局变量(FastAPI使用的unicorn启动时会用到)
app = context.run(lambda: WebRunner.get_context())
# 其它使用 FastAPI 实例 app 的代码
# ...
启动服务器
uvicorn example.main:app --host 127.0.0.1 --port 8000 --env-file .env
Contributors
有问题可以在issues开话题讨论,如果你有新的想法,创建新的feat或pref分支并提交PR。
License
Metadata
Release files for autoboot-web 0.9.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| autoboot_web-0.9.2.tar.gz | 14.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| autoboot_web-0.9.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.1 kB
Release files / autoboot_web-0.9.2.tar.gz
| Download URL | autoboot_web-0.9.2.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7662afdab316ba659461853659e8d6225ea0e9688652b9dbbd41eaef12d5ddeb
|
|
BLAKE2b-256 checksum How to use checksums |
06fc82c0a8c5ec7416ce5b01a4d07e65389255e376c5f61200c0557f841c1f19
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.65.0 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/1.5.0 colorama/0.4.6 CPython/3.11.6
|
Release files / autoboot_web-0.9.2-py3-none-any.whl
| Download URL | autoboot_web-0.9.2-py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07ade1b8269a726231a9e9dc3e55af05a129062da830dd6fde21b815458a183d
|
|
BLAKE2b-256 checksum How to use checksums |
44eb521c2163e465b300666188f1b54fcd37e90c66818b47f12138c7b51e27f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.16 tqdm/4.65.0 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/1.5.0 colorama/0.4.6 CPython/3.11.6
|
Security for autoboot-web 0.9.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.