Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 795ae72

Browse files
ibidaniasw101
andauthoredJul 10, 2020
Redirect if text query param missing (#20)
* Redirect if text query param missing * Update __init__.py Co-authored-by: Aaron Wislang <asw101@users.noreply.github.com>
1 parent ddc8298 commit 795ae72

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎4-azure-functions-python-vscode/sentiment/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
def main(req: func.HttpRequest) -> func.HttpResponse:
66
analyzer = SentimentIntensityAnalyzer()
77
text = req.params.get("text")
8+
if text is None:
9+
return func.HttpResponse(status_code=302, headers={"Location":req.url+"?text=I+Love+PyCon"})
810
scores = analyzer.polarity_scores(text)
911
sentiment = "positive" if scores["compound"] > 0 else "negative"
1012
return func.HttpResponse(sentiment)
11-
13+

0 commit comments

Comments
 (0)
Please sign in to comment.