Lessweb is a ready-to-use, production-grade Python web framework with the following goals:
- Ready-to-use: Easily parse configuration files, set up logging with ease, and dynamically override configuration items using environ variables.
- Production-grade: Built on the aiohttp ecosystem and boast powerful IOC capabilities.
- Pythonic: Support for the latest python version and the latest python syntax.
To install the latest lessweb for Python≥3.10, please run:
pip install lessweb
Save the code below in file main.py
:
from typing import Annotated
from lessweb import Bridge
from lessweb.annotation import Get
async def hello(*, who: str = 'world') -> Annotated[dict, Get('/')]:
return {'message': f'Hello, {who}!'}
def main():
bridge = Bridge()
bridge.scan(hello)
bridge.run_app()
if __name__ == '__main__':
main()
Start the application with the command below, it listens on http://localhost:8080
by default.
python main.py
Open your browser at http://localhost:8080
You will see the JSON response as:
{"message":"Hello, world!"}
Open your browser at http://127.0.0.1:8000?who=John
You will see the JSON response as:
{"message":"Hello, John!"}
Lessweb is offered under the Apache 2 license.
The latest developer version is available in a GitHub repository: https://github.com/lessweb/lessweb