Hi,
The php/html page will place the request to the python Api that will store the request in db (mysql or sqlite) with status in progress. Once the request was recorded it will be called a function that check the availability of the domain and return the expiring date. Based on the expiring date will be created a crontab job with python-crontab that will call a different Api endpoint to check the availability. At the end will be sent an email with availability of domain and, mark the record in db like complete, remove crontab job.
I think that this should be the approach for your project.
Have a nice day!