Hello guys
I have performed sentiment analysis in python using Vader library,but now I want to send this data to react front end.
How can I do it ?
For further actions, you may consider blocking this person and/or reporting abuse
Hello guys
I have performed sentiment analysis in python using Vader library,but now I want to send this data to react front end.
How can I do it ?
For further actions, you may consider blocking this person and/or reporting abuse
Arindam Majumder -
Arum Puri -
Mohammad Faisal -
Lucas Brogni -
Top comments (10)
Hello, you might want to set up a python
flask
API endpoint and make a request to that endpoint from your React app to fetch the data.Can't I do it using node.js
Why would you write an API in node.js if the sentiment analysis is a python script?
Cause I want to deploy through MERN stack my application.Also I don't know if sentiment analysis can be done in tensorflow or not
Ah okay. Not sure if I fully understand your situation, but here's what I suggest:
Write your python sentiment analysis script as a serverless function (e.g. for AWS Lambda). Build an API for the script and call the API endpoint from the React Frontend. The rest of your app can follow the MERN stack.
As far as I understand, you'll have to build an API for the python script no matter what; I don't see how it can communicate with node or react otherwise.
E.g. if your app must absolutely follow the MERN stack, the React layer would read from the node endpoint... Which would itself get data from the Python API. So why not just call the Python API directly?
If you think this is a viable approach, I can share some boilerplate code I use to make serverless python functions on AWS Lambda with API Gateway
Sure @jordan Lee, It would really help me
Sure :) But a heads-up first: please make sure you're willing to spend a bit of time learning AWS Lambda + API gateway and check that it's relevant to your needs. I don't want to accidentally send you down the wrong path if there's a better way to do it.
Anyway, here's the repo: github.com/jkhaui/serverless-pytho...
npm i serverless -g
to install the serverless framework globally.serverless offline
to edit your Python script locally. Test the API at localhost:4000serverless deploy
to host it on AWS Lambda. An endpoint URL should also be created automatically through API gateway.Any questions/problems, let me know. Also, you'll be prompted for your AWS credentials at some point during these steps
Oh and btw, you can delete all the Spacy code in handler.py and also delete the directory
en_core_web_sm-2.1.0
. That's just for demo purposes.Put your Python script in handler.py. This is the code that will let your script be accessed as an API:
sure Jordan, First I will also look into the alternatives. But I highly appreciate the help you provided :).Wish you good luck in your future endeavors.
No problem :) Thank you, and best of luck with your app too.