![]() ![]() This will be temporary and will only work as long as your Flask server is running. Another way is to expose your localhost as a publically available URL. One way would be to deploy the API and use the URL of the deployed API. Webhooks require a public API endpoint since they can not make requests to endpoints such as ‘’. Now you can run your flask server python3 _init_.py Exposing our localhost URL publically You can use different keys to access more data like issue labels etc. I read the docs and knew the keys for the JSON objects. This will be a standard endpoint that accepts POST requests. Now we need to create an endpoint to receive the request from the GitHub API. Create a simple Flask Serverįirst, let’s create a hello world endpoint. Let’s create an API to receive a request whenever a new Issue is created in a Github repo. This image was inspired by this articleĪs you might have noticed, a lot of requests are made and depending on how frequently we make requests, there might be a slight delay between the new issue being created and our API getting notified. Below is a comparison between polling and webhooks. Instead of us making periodic requests, we just give GitHub our API’s endpoint and whenever a new issue is created, a request will be made to the endpoint we gave to Github. What if GitHub makes a request to our API whenever a new issue is created. ![]() Basically, we would have to periodically make requests to check for a new issue. One way would be to build an API that would make a request every 1-2 minutes to check if a new issue is made and notify us. If you want to learn more about working with APIs, check out my article on working with APIs with Python or my article on working with APIs with JavaScript.Ĭonsider the Github API, what if we wanted to build an API that would send use an email every time a new issue is made in a repo. You make a GET/POST request to the API and you get a response back. What is a webhook?īefore talking about webhooks, let’s talk about APIs. We will also see how to expose our local hosts. We will also build a simple Flask server that can receive GitHub webhooks. This tutorial will be an introduction to the concept of webhooks. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |