Running complex calculations (using python/pandas) in a Django server -
i have developed restful api using django-rest-framework in python. developed required models, serialised them, set token authentication , other due diligence goes along it.
i built front-end using angular, hosted on different domain. setup cors modifications can access api required. seems working fine.
here problem. web app building financial application should allow user run complex calculations on server , send results front-end app can rendered charts , other formats. not know how or put these calculations.
i chose django back-end expected python me run such calculations wherever required. basically, when call particular api link on server, want able retrieve data database, multiple tables if required, , use data run calculations using python or library of python (pandas or numpy) , serve results of calculations response api call.
if daunting task, @ least want able use api retrieve data tables front-end, process data little using js, , send python function located on server processed data, , function run necessary complex calculations , respond results rendered charts / other formats.
can point me direction move here? looked resources online think unable find correct keywords search them. want shell code kind of thing integrate current backed using can call python scripts write run these calculations.
thanks in advance.
i assume question "how do these calculations in restful framework django?", think in case need move away idea.
you did correctly restful apis serve resources -- model.
a computation nothing that. see it, have 2 ways of achieving want:
1) write model represents results of computation , served using restful framework, computation being resource (can work nicely if store results in database way of caching)
2) add route/endpoint api, meant serve results of computation.
path 1: computation resource
create model, handles computation upon instantiation. set inheritance structure computations , implement interface computation models.
this way, when resource requested , restful framework wants serve resource, computational result served.
path 2: custom endpoint
add route computation endpoints /myapi/v1/taxes/compute.
in underlying controller of endpoint, load models need computation, perform computation, , serve result (probably json response).
you can still implement computations above mentioned inheritance structure. way, can instantiate computation object based on parameter (in above case taxes).
does give idea?
Comments
Post a Comment