qr_server
This project is the extension of Flask project (https://pypi.org/project/Flask/), aimed on fast creation of web-apps with minimalistic syntax. The solution provides support for basic HTTP-routing (with file sending), fast DTOs (data transfer objects for formalization and validation of response data), simple jwt-token system, role manager (database-side rights system) and configurable logging. See 'example' directory for a minimal working application built using this library
Usage example:
from qr_server.Server import MethodResult, QRContext
from qr_server.Config import QRYamlConfig
from qr_server.TokenManager import require_token, JwtTokenManager
from qr_server.FlaskServer import FlaskServer
def login(ctx: QRContext):
login = ctx.json_data['login']
password = ctx.json_data['password']
user_id = ctx.repository.check_credentials(login, password)
if user_id is None:
return MethodResult('wrong credentials', 500)
user = ctx.repository.get_user_data(user_id)
if user is None:
return MethodResult('account not found', 500)
jwt_token = ctx.managers['token_manager'].make_token(user_id)
return MethodResult(JwtDTO(jwt_token))
@require_token()
def user_info(ctx: QRContext, user_id):
user = ctx.repository.get_user_data(user_id)
if user is None:
return MethodResult('account not found', 500)
return MethodResult(UserInfoDTO(**user))
class AuthServer(FlaskServer, AuthRepository):
"""DI class"""
if __name__ == "__main__":
config = QRYamlConfig()
config.read_config('config.yaml')
host = config['app']['host']
port = config['app']['port']
token_man = JwtTokenManager()
token_man.load_config(config['jwt'])
server = AuthServer()
server.init_server(config['app'])
if config['app']['logging']:
server.configure_logger(config['app']['logging'])
server.register_manager(token_man)
server.register_method('/login', login, 'POST')
server.register_method('/info', user_info, 'GET')
server.run(host, port)
Metadata
Release files for qr-server 1.1.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qr_server-1.1.14.tar.gz | 10.9 kB | Without provenance | Details for qr_server-1.1.14.tar.gz |
Release files / qr_server-1.1.14.tar.gz
| Download URL | qr_server-1.1.14.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4e3d20db4059f12ac0d65ba76b59bfc371c3f32d76b0dcd28d7d21073e904d1
|
|
BLAKE2b-256 checksum How to use checksums |
adf64c1a91d9a4ee6eea581c26d5b992ca11b6cc570020601a82243fe242cbca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
|
Security for qr-server 1.1.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.