.. pyEchoNext documentation master file, created by sphinx-quickstart on Fri Apr 18 00:12:47 2025. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. pyEchoNext documentation ======================== .. toctree:: :maxdepth: 2 :caption: Article Docs: webframework_design webapp_creation routes_and_views requests_responses security mvc permissions ------------------ .. toctree:: :maxdepth: 2 :caption: Source code docs: pyechonext pyechonext.app pyechonext.middleware pyechonext.permissions pyechonext.request pyechonext.response pyechonext.static pyechonext.urls pyechonext.cache pyechonext.config pyechonext.apidoc_ui pyechonext.auth pyechonext.docsgen pyechonext.logging pyechonext.template_engine pyechonext.utils ------------------ 🌟 **EchoNext: The Future of Web** 🚀 ===================================== .. container:: .. raw:: html
EchoNext is a lightweight, fast and scalable web framework for Python Explore the docs » Why Choose pyEchoNext · Key Features · Getting Started · Basic Usage · Specification · Documentation · License .. raw:: html
.. raw:: html.. raw:: html
.. raw:: html.. raw:: html
.. EchoNext is a lightweight, fast and scalable web framework for Python [!CAUTION] At the moment, EchoNext is under active development, many things may not work, and this version is not recommended for use (all at your own risk) Welcome to **EchoNext**, where innovation meets simplicity! Are you tired of the sluggishness of traditional web frameworks? Want a solution that keeps pace with your ambitious apps? Look no further. EchoNext is your agile companion in the world of web development! [!NOTE] Versions below 0.7.14a are not recommended for use with gunicorn <23.0 due to the fact that they used an older version of gunicorn (<23.0), which was `vulnerable.. raw:: html
**Imagine** a lightweight framework that empowers you to create modern web applications with lightning speed and flexibility. With EchoNext, you’re not just coding; you’re building a masterpiece! Last stable version: 0.7.15 alpha .. Next Big Update: ASYNC & unicorn support Check Other My Projects ----------------------- - `SQLSymphony.. raw:: html
📚 Key Features --------------- - Intuitive API: Pythonic, object-oriented interface for interacting with routes and views. - Performance Optimization: Lazy loading, eager loading, and other techniques for efficient web queries. - Comprehensive Documentation: Detailed usage examples and API reference to help you get started. - Modular Design: Clean, maintainable codebase that follows best software engineering practices. - Extensive Test Coverage: Robust test suite to ensure the library’s reliability and stability. .. raw:: html.. raw:: html
⚙️ Functionality ---------------- - i18n/l10n localization with `hermes-langlib.. raw:: html
🚀 Getting Started ------------------ pyEchoNext is available on `PyPI.. raw:: html
⚙️ Dependency Injection ----------------------- pyEchoNext is universal, and you are free to use any Dependency-Injection framework. But we recommend using the specially developed `echonextdi.. raw:: html
Basic With Depends Injection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: python import os from pyechonext.app import ApplicationType, EchoNext from pyechonext.config import Settings from pyechonext.middleware import middlewares from pyechonext.mvc.controllers import PageController from pyechonext.urls import URL from echonextdi.containers.container import Container from echonextdi.depends import Depends from echonextdi.providers.callable_provider import CallableProvider class IndexController(PageController): def get(self, request, response, **kwargs): return "Hello" def post(self, request, response, **kwargs): return "Hello" def say_hello(name: str, phrase: str = 'Hello'): return f'{phrase} {name}' class Hello_Dependency: def __init__(self, say_hello): self.say_hello = say_hello container = Container() container.register("say_hello", CallableProvider(say_hello)) url_patterns = [URL(path="/", controller=IndexController)] settings = Settings( BASE_DIR=os.path.dirname(os.path.abspath(__file__)), TEMPLATES_DIR="templates" ) echonext = EchoNext( __name__, settings, middlewares, urls=url_patterns, application_type=ApplicationType.HTML, ) @echonext.route_page("/hello/{name}") def hello(request, response, name: str = "World", depend: Depends = Depends(container, Hello_Dependency)): response.body = depend().say_hello(name) Performance caching ~~~~~~~~~~~~~~~~~~~ .. code:: python import random from pyechonext.utils.performance import InMemoryPerformanceCache, SingletonPerformanceCache, performance_cached memorycache = InMemoryPerformanceCache perf = SingletonPerformanceCache(memorycache) @performance_cached(perf) def example_function(a: int = 10 ** 6): inside_circle = 0 for _ in range(a): x = random.uniform(-1, 1) y = random.uniform(-1, 1) if x ** 2 + y ** 2 <= 1: inside_circle += 1 return (inside_circle / a) * 4 if __name__ == '__main__': print('start') print(f'{example_function()} - Caching') print(f'{example_function()} - Cached') print(f'{example_function(10 ** 7)} - Caching new') Permissions ~~~~~~~~~~~ .. code:: python from pyechonext.permissions import ( Permission, Role, Resource, AccessControlRule, Policy, AgeRestrictionsABP, User, DefaultPermissionChecker, UserController, ) view_users_perm = Permission("view_users") edit_users_perm = Permission("edit_users") admin_role = Role("admin") admin_role.add_permission(view_users_perm) admin_role.add_permission(edit_users_perm) user_role = Role("user") user_role.add_permission(view_users_perm) user_resource = Resource("UserResource") policy = Policy() policy.add_rule(AccessControlRule(admin_role, view_users_perm, user_resource, True)) policy.add_rule(AccessControlRule(admin_role, edit_users_perm, user_resource, True)) policy.add_rule(AccessControlRule(user_role, view_users_perm, user_resource, True)) policy.add_rule(AccessControlRule(user_role, edit_users_perm, user_resource, False)) age_policy = AgeRestrictionsABP(conditions={"age": 18}, rules=policy.rules) age_policy.add_rule(AccessControlRule(user_role, view_users_perm, user_resource, True)) admin_user = User("admin", attributes={"age": 30}) admin_user.add_role(admin_role) young_user = User("john_doe", attributes={"age": 17}) young_user.add_role(user_role) permission_checker = DefaultPermissionChecker(policy) user_controller = UserController(permission_checker) def main(): assert user_controller.view_users(admin_user, user_resource) == ( "200 OK", "User edit form", ) assert user_controller.edit_users(admin_user, user_resource) == ( "200 OK", "User edit form", ) assert user_controller.edit_users(young_user, user_resource) == ( "403 Forbidden", "You do not have permission to edit users.", ) assert age_policy.evaluate(young_user, user_resource, view_users_perm) == False assert age_policy.evaluate(admin_user, user_resource, view_users_perm) == True if __name__ == "__main__": main() .. raw:: html.. raw:: html
🔧 Specifications ----------------- Security ~~~~~~~~ A security module created for hash functions and crypto-algorithms. Crypts ^^^^^^ Simple crypto-algorithms. PSPCAlgorithm ''''''''''''' Point Simple Password Crypt Algorithm. :: Base: AngryPassword Crypted: 00778.87999.74379.363401.558001.558001.96058.06107.711601.87999.13309.07469.50075 Decrypted: AngryPassword Base: S0mesd7623tds@&6^@_ Crypted: 51338.82165.83428.85374.62333.82165.558001.00778.237101.72744.05834.85374.53284.00778.558001.77588.39559.69024.19727 Decrypted: S0mesd7623tds@&6^@_ Base: PassWord Crypted: 00778.87999.74379.99267.558001.558001.96058.06107 Decrypted: PassWord Base: Pass Crypted: 558001.558001.96058.06107 Decrypted: Pass Example: .. code:: python from pyechonext.security.crypts import PSPCAlgorithm pspc = PSPCAlgorithm() passwords = ['AngryPassword', 'S0mesd7623tds@&6^@_', 'PassWord', 'Pass'] for password in passwords: print('Base:', password) print('Crypted:', pspc.crypt(password)) print('Decrypted:', pspc.decrypt(pspc.crypt(password))) print() Hashing ^^^^^^^ - Module: ``pyechonext.security.hashing`` HashAlgorithm ''''''''''''' Enum class with available hashing algorithms .. code:: python class HashAlgorithm(Enum): """ This class describes a hash algorithms. """ SHA256 = auto() SHA512 = auto() MD5 = auto() BLAKE2B = auto() BLAKE2S = auto() PlainHasher ''''''''''' A simple class for hashing text. Has no ‘salting’. .. code:: python hasher = PlainHasher(HashAlgorithm.BLAKE2S) old_hash = hasher.hash("TEXT") new_hash = hasher.hash("TEXT") if hasher.verify("TEXT", new_hash): # true print('Yes!') if hasher.verify("TEXT2", old_hash): # false print('Yes!') # Output: one "Yes!" SaltedHasher '''''''''''' A simple class for hashing text. Has hash salt. .. code:: python hasher = SaltedHasher(HashAlgorithm.BLAKE2S, salt='bob') old_hash = hasher.hash("TEXT") new_hash = hasher.hash("TEXT") if hasher.verify("TEXT", new_hash): # true print('Yes!') if hasher.verify("TEXT2", old_hash): # false print('Yes!') # Output: one "Yes!" View ~~~~ View is an abstract class, with abstract get and post methods (all descendants must create these methods). .. code:: python class View(ABC): """ Page view """ @abstractmethod def get(self, request: Request, response: Response, *args, **kwargs): """ Get :param request: The request :type request: Request :param response: The response :type response: Response :param args: The arguments :type args: list :param kwargs: The keywords arguments :type kwargs: dictionary """ raise NotImplementedError @abstractmethod def post(self, request: Request, response: Response, *args, **kwargs): """ Post :param request: The request :type request: Request :param response: The response :type response: Response :param args: The arguments :type args: list :param kwargs: The keywords arguments :type kwargs: dictionary """ raise NotImplementedError Example of view: .. code:: python class IndexView(View): def get(self, request: Request, response: Response, **kwargs): """ Get :param request: The request :type request: Request :param response: The response :type response: Response :param args: The arguments :type args: list :param kwargs: The keywords arguments :type kwargs: dictionary """ return "Hello World!" def post(self, request: Request, response: Response, **kwargs): """ Post :param request: The request :type request: Request :param response: The response :type response: Response :param args: The arguments :type args: list :param kwargs: The keywords arguments :type kwargs: dictionary """ return "Message has accepted!" Or you can return response: .. code:: python class IndexView(View): def get(self, request: Request, response: Response, **kwargs): """ Get :param request: The request :type request: Request :param response: The response :type response: Response :param args: The arguments :type args: list :param kwargs: The keywords arguments :type kwargs: dictionary """ return Response(request, body="Hello World!") def post(self, request: Request, response: Response, **kwargs): """ Post :param request: The request :type request: Request :param response: The response :type response: Response :param args: The arguments :type args: list :param kwargs: The keywords arguments :type kwargs: dictionary """ return Response(request, body="Message has accepted!") Tests coverage -------------- To test the web framework, PyTest with the pytest-cov plugin is used. You can look at the tests in `tests directory <./tests>`__ Documentation 🌍 ---------------- The main documentation is `here.. raw:: html
🤝 Contributing --------------- We welcome contributions from the community! If you’d like to help improve pyEchoNext, please check out the `contributing guidelines.. raw:: html
👥 Join the Community! ---------------------- If you find Echonext valuable and want to support the project: - Star on GitHub ⭐ - Share it with friends and colleagues! - Donate via cryptocurrency 🙌 Connect with fellow Echonext users: `Join our Telegram Chat.. raw:: html
🌟 Get Started Today! --------------------- Unlock your potential as a developer with Echonext. Don’t just build applications—craft experiences that resonate with your users! The possibilities are limitless when you harness the power of Echonext. **Happy Coding!** 💻✨ This README is designed to grab attention from the very first lines. It emphasizes the framework’s strengths and makes a compelling case for why developers should choose Echonext for their projects. Feel free to adjust any specific links or images to fit your project! License ------- Distributed under the GNU LGPL 2.1 License. See `LICENSE.. raw:: html
-------------- EchoNext is a lightweight, fast and scalable web framework for Python Copyright (C) 2024 Alexeev Bronislav (C) 2024 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA