uWeb, python3, uswgi compatible micro web platform
Project description
New and improved: µWeb3
Since µWeb inception we have used it for many projects, and while it did its job, there were plenty of rough edges. This new version intends to remove those and pull it into the current age.
µWeb3 is free software, distributed under the terms of the [GNU] General Public License as published by the Free Software Foundation, version 3 of the License (or any later version). For more information, see the file LICENSE
Notable changes
- wsgi complaint interface
- python3 native
- Better handling of strings and automatic escaping
- More options for template engines
- More options for SQL / database engines
Example projects
The following example applications for uWeb3 exist:
- uWeb3-scaffold: This is an empty project which you can fork to start your own website
µWeb3 installation
The easiest and quickest way to install µWeb3 is using Python's virtualenv
. Install using the setuptools installation script, which will automatically gather dependencies.
# Set up the Python3 virtualenv
python3 -m venv env
source env/bin/activate
# Install uWeb3
python3 setup.py install
# Or you can install in development mode which allows easy modification of the source:
python3 setup.py develop --user
# clone the uweb3scaffold project to get started
git clone git@github.com:underdarknl/uweb3scaffold.git
cd uweb3scaffold
python3 serve.py
Ubuntu issues
On some ubuntu setups venv is broken and therefore does not install the activation scripts.
# Set up the Python3 virtualenv on Ubuntu
python3 -m venv --without-pip env
source env/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python
deactivate
source env/bin/activate
# then proceed to install µWeb3 like before.
µWeb3 database setup
Setting up a database connection with µWeb3 is easy, navigate to the settings.ini file in the scaffold folder and add the following fields to the file:
[mysql] OR [sqlite]
host = 'host'
user = 'username'
password = 'pass'
database = 'dbname'
To access your database connection simply use the connection attribute in any class that inherits from PageMaker.
Config settings
If you are working on µWeb3 core make sure to enable the following setting in the config:
[development]
dev = True
This makes sure that µWeb3 restarts every time you modify something in the core of the framework aswell.
Routing
The default way to create new routes in µWeb3 is to create a folder called routes. In the routes folder create your pagemaker class of choice, the name doesn't matter as long as it inherits from PageMaker. After creating your pagemaker be sure to add the route endpoint to routes list in base/init.py.
New since v3
- In uweb3 init a class called HotReload
- In pagemaker init:
- A classmethod called loadModules that loads all pagemaker modules inheriting from PageMaker class
- A XSRF class
- Generates a xsrf token and creates a cookie if not in place
- In requests:
- Self.method attribute
- self.post.form attribute. This is the post request as a dict, includes blank values.
- Method called Redirect #Moved from the response class to the request class so cookies that are set before a redirect are actually persist to the next request.
- Method called DeleteCookie
- An if statement that checks string like cookies and raises an error if the size is equal or bigger than 4096 bytes.
- AddCookie method, now supports multiple calls to Set-Cookie setting all cookies instead of just the last.
- In pagemaker/decorators:
- Loggedin decorator that validates if user is loggedin based on cookie with userid
- Checkxsrf decorator that checks if the incorrect_xsrf_token flag is set
- In templatepaser:
- Its possible to register tags to the parser, for example in your _postInit call
- Its possible to register 'Just in Time' tags to the parser, which will be evaluated only when needed.
- In libs/sqltalk, use of PyMysql instead of c mysql functions
- Connections
- All Connections are now all availabe on the self.connections member of the pagemaker, regardless of what type of backend they connect to
- Cookies (signed and safe) are available as a connection
- Config files (read/write) are available as a connection
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
Built Distribution
File details
Details for the file uWebthree-3.0.1.tar.gz
.
File metadata
- Download URL: uWebthree-3.0.1.tar.gz
- Upload date:
- Size: 111.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.56.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bd982bf9f9da61a7e2031cf11ce14240c741356a2cd2fb65b18534c82fbbacf |
|
MD5 | 435cf4eda18a973b3d72efb762aa4c9c |
|
BLAKE2b-256 | d2a5935ebddb6f14d3e88f1ba30607fb4057da9a0cf73dd5861558b53713853c |
File details
Details for the file uWebthree-3.0.1-py3-none-any.whl
.
File metadata
- Download URL: uWebthree-3.0.1-py3-none-any.whl
- Upload date:
- Size: 107.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.56.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0f636f6125093039a38ce6807ede47766ea403f686247cee56126fad7eaadae |
|
MD5 | b3d6401ff58b94d0cfd0c11fc96ee4d8 |
|
BLAKE2b-256 | 2c56a751c36dcd31526bd85a73b6add01f7d91e65dd8d4fe6c5ec058c4077599 |