Planet Python

Ned Batchelder: Cogged GitHub profile

Cog is a tool that allows users to incorporate dynamic Python-generated content within static files. The author utilized Cog to generate their GitHub profile page, customizing it through a README.md file hosted in a repository with their username. The README.md file contains a blend of static text, Python code that generates content, and the generated content itself. The code primarily focuses on creating shields.io badges using Python functions for generating image URLs and Markdown syntax. Example functions include shields_url for creating badge URLs, md_image for inserting Markdown images, and badge for combining the two. Generated content is printed and inserted into the file, such as a badge for a Discord server. The page pulls data from multiple URLs, including the author's blog, to dynamically update content. The resulting profile page seamlessly integrates static and generated content. This approach eliminates manual data copying and provides automatic updates. Cog simplifies the process of creating customizable and dynamic web pages. The author's GitHub profile serves as a practical example of Cog's capabilities.
favicon
nedbatchelder.com
nedbatchelder.com