A pythonic web framework
Project description
lessweb
「嘞是web」
Lessweb is an extremely easy-to-use python web framework with the following goals.
- Simple and efficient: based on the aiohttp library IOC capabilities, native support for configuration loading and logging settings to meet production-level development requirements
- Pythonic: support for the latest python version and the latest python syntax
Install lessweb
To install the latest lessweb for Python 3, please run:
pip3 install lessweb
Hello, world!
Save the code below in file index.py
:
from lessweb import Bridge, get_mapping
@get_mapping('/')
async def hello():
return {'message': 'Hello, world!'}
def main():
bridge = Bridge()
bridge.add_route(hello)
bridge.run_app()
if __name__ == '__main__':
main()
Start the application with the command below, it listens on http://localhost:8080/
by default.
python3 index.py
Setting port
Save the code below in file config.toml
:
[bootstrap]
port = 80
Then change the code to:
def main():
bridge = Bridge(config='config.toml')
bridge.add_route(hello)
bridge.run_app()
Once you run it, you can access http://localhost/
with your browser.
You can also use environment variables to override the configuration file's contents, e.g. run BOOTSTRAP_PORT=8081 python3 index.py
, then it listens on http://localhost:8081
.
License
Lessweb is offered under the Apache 2 license.
Source code
The latest developer version is available in a GitHub repository: https://github.com/lessweb/lessweb
Cookbook
https://github.com/lessweb/lessweb/wiki
Cookbook【中文】:
http://www.lessweb.cn
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
File details
Details for the file lessweb-1.5.1.tar.gz
.
File metadata
- Download URL: lessweb-1.5.1.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d987977f8453f5cac3932758c3d733400932c0e2b39bdcb81c1cdd5258808b31 |
|
MD5 | b02c8226f5ce2ce52a612d0442840a4d |
|
BLAKE2b-256 | 2556636859143cf94936cf3999142a411764262daa998e658c3de9aa7bfc1fd1 |
File details
Details for the file lessweb-1.5.1-py3-none-any.whl
.
File metadata
- Download URL: lessweb-1.5.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55bde1aa913e4a6e22ab877db954f3f46608c98a7ef64c6f54653321023aae87 |
|
MD5 | 16d8b5d09e29f3439cc3861175cf5c2d |
|
BLAKE2b-256 | 28ae7a5d10ff8d53547f56499fa3b2a950091b439b225ad1ae9d791d6a49c42e |