Package: easy-route
easy-route🚦A simple but effective Routing system for Flask projectsExplore the docs »Report Bug·Request FeatureTable of ContentsAbout The ProjectGetting StartedPrerequisitesInstallationUsageContributingLicenseContactAbout The Projecteasy-route is a Python 🐍 package 📦 that will allow you to define the routes for your Flask projects in a simple yet
effective way.A Route object is composed by a few configurable and extensible components:MiddlewaresControllerMiddlewaresThe middleware is the first component in the Route stack.It takes care of operations like data validation, authentication check, ...Each route can contain zero, one or more middlewares that will be executed before the controller one by one, in
insertion order.A middleware can stop the Route execution by returning a Response object, for instance it may return aHTTP 400response if the input data is invalid, or aHTTP 401if the user is not authenticated.If the middleware succeeds, it returnsNoneto tell the Route to go ahead with other components.(back to top)ControllersThe controller is the core of every route, as it implements the logic behind the route.After all the middlewares have been validated, the Route calls the controller and returns its result.A Route, by definition, can contain only a single Controller.(back to top)Getting StartedPrerequisitesThis package containes a few dependencies, specified inrequirements.txt.After cloning the repo, you can install the dependencies with:pipinstall-rrequirementsYou can also install the requirements in a virtual environment:python-mvenv.venvsource.venv/bin/activate
pipinstall-rrequirements(back to top)InstallationTo use this package in your projects you can either install the latest release from PyPi or install a specific version
from sources.To install it from PyPi you can usepip:pipinstalleasy-routeYou can also usepipto install a specific version from this repo:pipinstallgit+https://github.com/en0mia/easy-routePlease, refer to thepip docsfor details about selecting the tag, version or branch.(back to top)UsageThe usage of this package is pretty straightforward.Firstly, you have to create a Route object:route=Route(request,MyController())Then you can add one or more middleware(s):route.add_middleware(MyMiddleware())# Or, to add more than one middleware at once:route.add_middlewares([MyMiddleware(),SecondMiddleware()])After the middlewares you can run the route and return its response:returnroute.dispatch()(back to top)ContributingContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make aregreatly appreciated.If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull Request(back to top)LicenseDistributed under the MIT License. SeeLICENSEfor more information.(back to top)ContactProject Link:https://github.com/en0mia/easy-routeThis templateKudos for this README template toothneildrew.You can find the repohere.(back to top)