Created
January 18, 2022 17:17
-
-
Save balvinder294/160ba5e1d5997c2213b5b0d9b2fc1670 to your computer and use it in GitHub Desktop.
Coal API for blurt.blog | https://blurt.blog/@tekraze
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
#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