Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,37 @@ def overflow():

resp_qs = ['Stack Overflow Top Questions for "%s"\n' % text]
resp_qs.extend(map(get_response_string, qs[:MAX_QUESTIONS]))

if len(resp_qs) == 1:
resp_qs.append(('No questions found. Please try a broader search or '
'search directly on '
'<https://stackoverflow.com|StackOverflow>.'))

# print('\n'.join(resp_qs))
else:
for resp_q in resp_qs:
# split with " " by 3 times
resp_q = resp_q.split(' ', 2)

# Select the the third element of the list
# which is the url of the question
url = resp_q[2]
# Look for "|" and add whitespaces around it
url = url.replace('|', ' | ')

# Add the url back to the list
resp_q[2] = url

# Join the list back to a string
resp_q = ' '.join(resp_q)

print(resp_q)

return Response('\n'.join(resp_qs),
content_type='text/plain; charset=utf-8')


@app.route('/')
def hello():
return redirect('https://github.com/karan/slack-overflow')

return 'Hello, World!'

if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
Expand Down