Last active
November 12, 2015 18:23
-
-
Save gduverger/a6b6328b4fcfb08267b7 to your computer and use it in GitHub Desktop.
How Fitmeal replies to text messages with nutrition facts (edited snippet)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reply(request): | |
""" | |
Reply to a text message with nutrition facts (edited snippet) | |
""" | |
args = {} | |
if request.method == 'POST': | |
# Get the text message | |
text = request.POST.get('text') | |
# Find the food | |
features = app_process.extract_features(text) | |
# Find the nutrition facts | |
nutrients = app_process.compute_nutrients(features) | |
# Write the response | |
response = app_process.compose_response(nutrients) | |
if response: | |
args.update({'response': response}) | |
else: | |
logger.error(text) | |
return render_to_response('reply.xml', args, context_instance=RequestContext(request), content_type='application/xml') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment