Skip to main content

A simple Flask routing package.

Project description


easy-route🚦

A simple but effective Routing system for Flask projects
Explore the docs »

Report Bug · Request Feature

Contributors Forks Stargazers Issues MIT License

Quality Gate Status Coverage Security Rating

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

easy-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:

  • Middlewares
  • Controller

Middlewares

The 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 a HTTP 400 response if the input data is invalid, or a HTTP 401 if the user is not authenticated.

If the middleware succeeds, it returns None to tell the Route to go ahead with other components.

(back to top)

Controllers

The 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 Started

Prerequisites

This package containes a few dependencies, specified in requirements.txt.

After cloning the repo, you can install the dependencies with:

pip install -r requirements

You can also install the requirements in a virtual environment:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements

(back to top)

Installation

To 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 use pip:

pip install easy-route

You can also use pip to install a specific version from this repo:

pip install git+https://github.com/en0mia/easy-route

Please, refer to the pip docs for details about selecting the tag, version or branch.

(back to top)

Usage

The 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:

return route.dispatch()

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly 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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Project Link: https://github.com/en0mia/easy-route

This template

Kudos for this README template to othneildrew.

You can find the repo here.

(back to top)

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

easy_route-0.0.2.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easy_route-0.0.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file easy_route-0.0.2.tar.gz.

File metadata

  • Download URL: easy_route-0.0.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for easy_route-0.0.2.tar.gz
Algorithm Hash digest
SHA256 84d215d25de32af78ec104e574650f193074094c2b503a8cc289a561e254155d
MD5 88dfe5ec2317b418f1fca8f1828b8521
BLAKE2b-256 1dda057ca761c3d018a7dfc667271e64f03dc0de6e08fe376f02e2c75cb952bb

See more details on using hashes here.

File details

Details for the file easy_route-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: easy_route-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for easy_route-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c5b96e2e8002e458cf16c355279ae641098b659446cfe116ce38b6ec428b3733
MD5 14f2cd8744b00629d8b305905d4d19d3
BLAKE2b-256 a81906095cfd1ebdf5e5d63b9b33388320c388ac2e1cc7850cc1d4f8ccac3cdb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page