Last active
May 25, 2022 14:50
-
-
Save simonw/b6dbb230d755c33490087581821d7082 to your computer and use it in GitHub Desktop.
A Datasette plugin in a gist - see https://simonwillison.net/2022/Apr/24/pip-install-github/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datasette import hookimpl | |
from datasette.utils.asgi import Response | |
import os | |
REDACT = {"GPG_KEY"} | |
async def env(request): | |
output = [] | |
for key, value in os.environ.items(): | |
if key not in REDACT: | |
output.append("{}={}".format(key, value)) | |
return Response.text("\n".join(output)) | |
@hookimpl | |
def register_routes(): | |
return [ | |
(r"^/-/env$", env) | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from setuptools import setup | |
VERSION = "0.1" | |
setup( | |
name="datasette-expose-some-environment-variables", | |
description="Expose environment variables in Datasette at /-/env", | |
author="Simon Willison", | |
license="Apache License, Version 2.0", | |
version=VERSION, | |
py_modules=["datasette_expose_some_environment_variables"], | |
entry_points={ | |
"datasette": [ | |
"expose_some_environment_variables = datasette_expose_some_environment_variables" | |
] | |
}, | |
install_requires=["datasette"], | |
) |
I turned this into a released plugin: https://github.com/simonw/datasette-unsafe-expose-env and https://pypi.org/project/datasette-unsafe-expose-env/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can install this plugin with: