This API is developed to explore more about Flask and RESTful APIs.
Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions.
Flask was created by Armin Ronacher of Pocoo, an international group of Python enthusiasts formed in 2004.According to Ronacher, the idea was originally an April Fool's joke that was popular enough to make into a serious application.
Try this API on : https://vast-river-42197.herokuapp.com/api
NOTE : The app is currently stopped due to change in Heroku's free tier policy. I am planning to deploy this app on another free tier soon. Thanks
Recommend using Anaconda. Anaconda does not come with Flask/Requests, so you will need to install those seperately.
pip install -r requirements.txt
For additional information on installing Flask & Profanity: Flask, Profanity
python test_api.py
Using CURL:
curl -X GET https://vast-river-42197.herokuapp.com/api -d query='I love that movie!'
curl -X GET https://vast-river-42197.herokuapp.com/api -d query='that movie was shit!'
Using Python:
heroku_url = 'https://vast-river-42197.herokuapp.com/api'
data = {"query":"I love that movie!"}
response = requests.get(heroku_url, data)
data = {"query":"that movie was shit!"}
response = requests.get(heroku_url, data)
{
"profanity_result": {"profanity_check":false},
"sentiment_result": {"compound":0.6696,"neg":0.0,"neu":0.308,"pos":0.692}
}
{
"profanity_result": {"profanity_censored":"that movie was @%@!","profanity_check":true},
"sentiment_result": {"compound":0.0,"neg":0.0,"neu":1.0,"pos":0.0}
}