Plugin que implementa criação de rotas com orientação a objetos.
Plugin para micro-framework bottle para simplificar a criação de rotas utilizando Orientação a Objetos.
Para utilizar este plugin é necessário instalar o bottle. Pode ser o passo a passo da documentação: https://bottlepy.org/docs/0.12/tutorial.html#installation ou apenas com o comando abaixo:
pip install bottle
Depois pode instalar o plugin com o comando:
pip install BottleRoute
Esse plugin vai trazer o arquivo RouteExt para o seu site-package então você poderá utilizar da seguinte forma:
from bottle import Bottle
from RouteExt import set_controller_handler, Controllers
class TesteController(Controllers):
url = "/"
def get(self):
return f"A url é: {self.url}"
app = set_controller_handler(Bottle)
app.register(obj=TesteController())
app.run()
Desta forma ele vai adicionar o método register a abstração do Bottle e vai poder ser invocado passando um objeto subclasse da classe Controller que implemente os verbos HTTP para URL. No exemplo acima são criados os verbos GET, POST, PUT e DELETE para a rota /, como não foi definido na classe TesteController() os métodos POST, PUT, DELETE, caso fossem requisitados retornáriam um erro informando Method not implemented.
Também é possível utilizar rotas dinamicas:
from bottle import Bottle
from RouteExt import set_controller_handler, Controllers
class TesteController(Controllers):
url = "/<nome>"
def get(self, nome):
return f"O parametro na rota é:: {nome}"
app = set_controller_handler(Bottle)
app.register(obj=TesteController())
app.run()
Metadata
Release files for BottleRoutes 2020.8.20
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 |
|---|---|---|---|---|
| BottleRoutes-2020.8.20.tar.gz | 2.6 kB | Without provenance | Details for BottleRoutes-2020.8.20.tar.gz |
Release files / BottleRoutes-2020.8.20.tar.gz
| Download URL | BottleRoutes-2020.8.20.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13140ded64af7b75001995d4bc92ea24545a63ee4165059b1c078e4f0273c88a
|
|
BLAKE2b-256 checksum How to use checksums |
f0c17b262885d28d72488cbc65a6aaf07ab829c1201b41ce90efe4044416c126
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
|
Security for BottleRoutes 2020.8.20
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.