Skip to content

Instantly share code, notes, and snippets.

@balvinder294
Created January 18, 2022 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save balvinder294/160ba5e1d5997c2213b5b0d9b2fc1670 to your computer and use it in GitHub Desktop.
Save balvinder294/160ba5e1d5997c2213b5b0d9b2fc1670 to your computer and use it in GitHub Desktop.
Coal API for blurt.blog | https://blurt.blog/@tekraze
#author @tekraze
import falcon
import requests
coalList = "https://gitlab.com/blurt/openblurt/coal/-/raw/master/coal.json"
class CoalList:
def on_get(self, req, resp):
response = requests.get(coalList)
coal_json = response.json()
response.close()
jsonArr = []
for key, value in coal_json.items():
data = {}
data['name'] = key
data['reason'] = value['reason']
data['notes']= value['notes']
jsonArr.append(data)
resp.media = jsonArr
middle = falcon.CORSMiddleware(
allow_origins="*"
)
api = falcon.App(middleware=middle)
api.add_route('/', CoalList())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment