Seatools Flask Web Starter
Project description
seatools flask 启动器
该框架必须和seatools-starter-server-*的包集成配合使用, 这里以seatools-starter-server-uvicorn为例
使用指南
- 安装,
poetry add flask seatools-starter-server-uvicorn seatools-starter-web-flask - 配置
config/application.yml如下:
seatools:
server:
# 此处为uvicorn参数配置
uvicorn:
host: 0.0.0.0
port: 8000
workers: 1
reload: true
# 此处为flask配置
flask:
# 与 Flask 参数一致
import_name: seatools.ioc.server.app
static_folder: static
template_folder: templates
...
- 使用, 通过定义ioc容器函数加载
import abc
from seatools.ioc import Autowired, Bean
from flask import Flask
# 添加路由
from flask import Flask
@Bean
def api_controller(app: Flask):
@app.get('/')
def hello():
return 'hello flask'
class Service(abc.ABC):
def hello(self):
raise NotImplementedError
# flask 与 seatools 的集成注入
@Bean
class ServiceA(Service):
def hello(self):
return "serviceA"
@Bean
def a2_router(app: Flask, service: Service): # 具体注入方式见seatools
@app.get('/service')
def service():
return service.hello() # return hello flask
- 运行, 具体见
seatools-starter-server-*,seatools-starter-server-uvicorn
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file seatools_starter_web_flask-1.0.0.tar.gz.
File metadata
- Download URL: seatools_starter_web_flask-1.0.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1154d3bc5d9be4de0e4d5527c99b0ba3e0399cfe556c66aa1df062c04dc85f99
|
|
| MD5 |
efa86b1f691739b777e851ccd40f9c8c
|
|
| BLAKE2b-256 |
af4a598843dd9da017cca696760d7c6254a38a74b08c01f412cf1cbc74cc58a3
|
File details
Details for the file seatools_starter_web_flask-1.0.0-py3-none-any.whl.
File metadata
- Download URL: seatools_starter_web_flask-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd6bf3a92737e97ecaf7bf4c76db78c991526c495d7119e906c1dfb753d56e1c
|
|
| MD5 |
f3c9a742268cff557b65569b096c4f34
|
|
| BLAKE2b-256 |
a3efbb376f817c284d6c866733fdb35469eae3e85d4566de17f58b9f1a4156d3
|