Skip to main content

Seatools Flask Web Starter

Project description

Seatools Flask Starter

This framework must be used in conjunction with the seatools-starter-server-* packages, using seatools-starter-server-uvicorn as an example here.

中文文档

Usage Guide

  1. Install with poetry add flask seatools-starter-server-uvicorn seatools-starter-web-flask
  2. Configure config/application.yml as follows:
seatools:
  server:
    # Here are the uvicorn parameter configurations
    uvicorn:
      host: 0.0.0.0
      port: 8000
      workers: 1
      reload: true
  # Here are the Flask configurations
  flask:
    # Consistent with Flask parameters
    import_name: seatools.ioc.server.app
    static_folder: static
    template_folder: templates
    ...
  1. Usage, load by defining ioc container functions
import abc
from seatools.ioc import Autowired, Bean
from flask import Flask

# Add route
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 integration with seatools ioc injection
@Bean
class ServiceA(Service):

    def hello(self):
        return "serviceA"

@Bean
def a2_router(app: Flask, service: Service):  # Specific injection method see seatools

    @app.get('/service')
    def service():
        return service.hello() # return hello flask
  1. Run, see seatools-starter-server-*, example: seatools-starter-server-uvicorn

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seatools_starter_web_flask-1.0.2.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seatools_starter_web_flask-1.0.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file seatools_starter_web_flask-1.0.2.tar.gz.

File metadata

File hashes

Hashes for seatools_starter_web_flask-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5a411788710cb755cd2a4a41b9c3ffcc7b34f0f175721b3941116f9bc2b0282c
MD5 5095982e0aa733117288bee0be9ad94f
BLAKE2b-256 794f1a663426ccaaeba85a0894ce6b4a77df9a5f8feeb0ea96840335b9169ba8

See more details on using hashes here.

File details

Details for the file seatools_starter_web_flask-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for seatools_starter_web_flask-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6a9fbe359823fb90ff2a2e1337861213df141a229e0c22fcd771e6d929acf6e
MD5 fa2e3c5eee43a58617cc1c9a602e91c1
BLAKE2b-256 51b55b9b361203de171d819efedd4dc218f8f071f049cfb058bafc9043e4dc0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page