npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

python-link

v1.90.0

Published

Python no frontend usando só a tag <link>

Readme

PyLink

Python no frontend usando só a tag <link>

PyLink é um framework web inovador que permite integrar arquivos Python (.py) diretamente em arquivos HTML usando a tag <link rel="pylink">, de forma simples e elegante.

Instalação

pip install pylink

Ou instale em modo de desenvolvimento:

pip install -e ".[dev]"

Uso Rápido

1. Crie um novo projeto

pylink new meu-projeto
cd meu-projeto

2. Execute o servidor de desenvolvimento

pylink dev

3. Abra no navegador

Acesse http://127.0.0.1:8000

Como Funciona

Inclua componentes Python no HTML

<!DOCTYPE html>
<html>
<head>
    <!-- Carregue o runtime -->
    <script src="/pylink-runtime.js"></script>
    
    <!-- Carregue componentes Python via <link> -->
    <link rel="pylink" href="components/counter.py" type="text/python">
</head>
<body>
    <!-- Use o componente -->
    <py-counter titulo="Meu Contador" inicial="0"></py-counter>
</body>
</html>

Crie componentes Python

# components/counter.py
from pylink import PyComponent, State, state

class Counter(PyComponent):
    count: State[int] = state(0)
    
    def __init__(self, titulo="Contador", inicial=0, **props):
        super().__init__(**props)
        self.props.titulo = titulo
        self.count.value = inicial
    
    def render(self) -> str:
        return f"""
<div class="counter">
    <h3>{self.props.titulo}</h3>
    <div class="value">{self.count.value}</div>
    <button @click="incrementar">+</button>
    <button @click="decrementar">-</button>
</div>
"""
    
    def incrementar(self):
        self.count.value += 1
    
    def decrementar(self):
        self.count.value -= 1

Comandos CLI

| Comando | Descrição | |---------|-----------| | pylink new <nome> | Cria um novo projeto | | pylink dev | Inicia servidor de desenvolvimento com hot reload | | pylink build | Gera versão estática para produção | | pylink run | Executa em modo produção | | pylink --version | Mostra a versão |

Estrutura do Projeto

meu-projeto/
├── app/
│   ├── components/    # Componentes Python
│   │   └── counter.py
│   ├── services/      # Serviços
│   └── pages/         # Páginas
├── static/            # Arquivos estáticos (CSS, JS)
├── templates/         # Templates HTML
├── pylink.json        # Configuração
└── pyproject.toml

API Reference

PyComponent

Classe base para componentes.

from pylink import PyComponent

class MyComponent(PyComponent):
    def __init__(self, **props):
        super().__init__(**props)
    
    def render(self) -> str:
        return "<div>Hello World</div>"

State

Estado reativo para componentes.

from pylink import State, state

class MyComponent(PyComponent):
    # Usando decorador
    count = state(0)
    
    # Ou criando diretamente
    def __init__(self):
        self.value = State(100)

Props

Propriedades passadas via atributos HTML.

class MyComponent(PyComponent):
    def __init__(self, titulo="Default", **props):
        super().__init__(**props)
        self.props.titulo = titulo  # Acessar via self.props

Servidor FastAPI

O PyLink inclui um servidor FastAPI pronto para uso:

# app/main.py
from pylink import create_app

app = create_app(
    static_dir="static",
    templates_dir="templates",
    app_dir="app",
    debug=True
)

Execute com:

pylink run
# ou
uvicorn app.main:app --reload

Browser Support

PyLink usa Pyodide (Python em WebAssembly) e requer:

  • Chrome 80+
  • Firefox 75+
  • Safari 14.1+
  • Edge 80+

Licença

MIT License