You really don't want my solution to this question (because I don't have one). Instead, you want to edit the question to contain all the information which would be needed by an API for JavaScript expert (and/or a Python GP Service guru), with a complete description of the platforms, versions of software involved, data, and an exact description of what "intersect polygon details with angles" means (with a sketch or other graphic to explain).
- V