Skip to content

Commit 795ae72

Browse files
ibidaniasw101
andauthored
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

+3-1
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)