Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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)
]
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"],
)
@simonw
Copy link
Author

simonw commented Apr 24, 2022

You can install this plugin with:

datasette install https://gist.github.com/simonw/b6dbb230d755c33490087581821d7082/archive/872818f6b928d9393737eee541c3c76d6aa4b1ba.zip

@simonw
Copy link
Author

simonw commented May 25, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment