{"library":"pecan","title":"Pecan Web Framework","description":"Pecan is a lean Python web framework (version 1.8.0) that uses an object-dispatching style for routing, inspired by CherryPy, TurboGears, and Pylons. It focuses on building HTTP-based applications with minimal dependencies, rather than being a 'full-stack' solution. The project maintains an active development status with regular releases addressing Python version compatibility and feature enhancements.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install pecan"],"cli":null},"imports":["from pecan import expose","from pecan import make_app","from pecan import conf","from pecan.rest import RestController"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom wsgiref.simple_server import make_server\n\nfrom pecan import make_app, expose\n\n# app.py\nclass RootController(object):\n    @expose()\n    def index(self):\n        return 'Hello, Pecan!'\n\n    @expose('json')\n    def hello(self, name='World'):\n        return {'message': f'Hello, {name}!'}\n\n# config.py (simulated for quickstart)\nconfig = {\n    'root': 'app.RootController',\n    'template_path': 'templates',\n    'debug': True,\n    'app': {\n        'modules': ['app'],\n        'static_root': 'public'\n    },\n    'server': {\n        'port': os.environ.get('PORT', '8080'),\n        'host': '0.0.0.0'\n    }\n}\n\n# To run this, you would typically use `pecan serve config.py`\n# For a self-contained example:\nif __name__ == '__main__':\n    app = make_app(config['root'], **config['app'])\n    server = make_server(config['server']['host'], int(config['server']['port']), app)\n    print(f\"Serving Pecan on http://{config['server']['host']}:{config['server']['port']}\")\n    print(\"Visit / and /hello?name=Pecan\")\n    try:\n        server.serve_forever()\n    except KeyboardInterrupt:\n        pass","lang":"python","description":"This minimal example demonstrates how to define a `RootController` with two exposed methods (`index` and `hello`). The `make_app` function initializes the WSGI application using this controller and a simple configuration. To run a Pecan application, the standard method is `pecan serve config.py`, where `config.py` contains the application's configuration. The `if __name__ == '__main__':` block provides a way to run it directly for demonstration purposes without the `pecan` command-line tool, serving on `0.0.0.0:8080`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}