I am trying to use mailgun's api on a landing page made through unbounce.com, however I discovered that I can't make requests client side. I do have django set up, so, I'd like to use that to make api calls to mailgun instead.
So, my question is how do I create using django-rest-framework, an API that would make the api calls for me and return the response. I have used drf before, but mostly serializing models, and this time I'd like to make a function-based api
I expect to make a call to mailgun and pass a parameter called email so that I can use something like domain.com/api/mailgun/email="email@email.com"
You can use APIView for your endpoint and requests library for mailgun api
class MailView(APIView):
def get(request):
email = request.query_params.get('email', None)
"""
some valdiations ..
"""
response = requests.get('http://mailgun-api/')
return Response(data=response.json())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.