# Giphy integration?

**URL:** <https://forum.mattermost.com/t/giphy-integration/510>\
**Category:** Troubleshooting\
**Created:** [November 17, 2015, 1:57am UTC](https://forum.mattermost.com/t/giphy-integration/510 "2015-11-17T01:57:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![booksprint](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/booksprint/32/1636_2.png) [@booksprint](https://forum.mattermost.com/u/booksprint)\
**Post date:** [November 17, 2015, 1:57am UTC](https://forum.mattermost.com/t/giphy-integration/510/1 "2015-11-17T01:57:58Z")

</div>

hi

Anyone want to share with me the secret to getting giphy integrated with v1.2.1? 🙂

I followed the recipe but I get an error in the python when the request is handled:

> File “/usr/lib/python2.7/SocketServer.py”, line 295, in \_handle\_request\_noblock  
> self.process\_request(request, client\_address)  
> File “/usr/lib/python2.7/SocketServer.py”, line 321, in process\_request  
> self.finish\_request(request, client\_address)  
> File “/usr/lib/python2.7/SocketServer.py”, line 334, in finish\_request  
> self.RequestHandlerClass(request, client\_address, self)  
> File “/usr/lib/python2.7/SocketServer.py”, line 649, in **init**  
> self.handle()  
> File “/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py”, line 217, in handle  
> rv = BaseHTTPRequestHandler.handle(self)  
> File “/usr/lib/python2.7/BaseHTTPServer.py”, line 340, in handle  
> self.handle\_one\_request()  
> File “/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py”, line 251, in handle\_one\_request  
> elif self.parse\_request():  
> File “/usr/lib/python2.7/BaseHTTPServer.py”, line 253, in parse\_request  
> self.send\_error(400, “Bad request version (%r)” % version)  
> File “/usr/lib/python2.7/BaseHTTPServer.py”, line 364, in send\_error  
> self.log\_error(“code %d, message %s”, code, message)  
> File “/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py”, line 273, in log\_error  
> self.log(‘error’, \*args)  
> File “/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py”, line 279, in log  
> \_log(type, ‘%s - - [%s] %s\n’ % (self.address\_string(),  
> File “/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py”, line 267, in address\_string  
> return self.environ[‘REMOTE\_ADDR’]  
> AttributeError: ‘WSGIRequestHandler’ object has no attribute ‘environ’

---

<div class="post-metadata">

**Author:** ![jwilander](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jwilander/32/8440_2.png) [@jwilander](https://forum.mattermost.com/u/jwilander)\
**Post date:** [November 17, 2015, 3:03pm UTC](https://forum.mattermost.com/t/giphy-integration/510/2 "2015-11-17T15:03:19Z")

</div>

Hi @booksprint,

Hmmm, that’s not an issue I’ve seen before. Can you provide me some more details on your setup? For example what OS you’re running it on, and anything else you might think is relevant.

Also, does hitting the root handler work? Basically hitting `youintegrationserver.com/` should return “OK” as the body of the HTTP response

---

<div class="post-metadata">

**Author:** ![reach3r](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/reach3r/32/210_2.png) [@reach3r](https://forum.mattermost.com/u/reach3r)\
**Post date:** [November 17, 2015, 3:42pm UTC](https://forum.mattermost.com/t/giphy-integration/510/3 "2015-11-17T15:42:56Z")

</div>

Hi,  
I found the “production” instructions to be rather unrefined regarding the web server based install.

Maybe this can help:

First make sure you have set up the variables via the .bash\_profile. Then make sure in the outgoing hook configuration for your Mattermost install to give the precise address of the python based webserver.  
For me this is: [http://localhost:8066/new\_post](http://localhost:8066/new_post)  
as I installed it on the same host as Mattermost and changed the port to one above Mattermost. Finally paste the token from Mattermost to the .bash\_profile and source it again.  
After starting the server the gif: command should work.

---

<div class="post-metadata">

**Author:** ![booksprint](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/booksprint/32/1636_2.png) [@booksprint](https://forum.mattermost.com/u/booksprint)\
**Post date:** [November 17, 2015, 6:49pm UTC](https://forum.mattermost.com/t/giphy-integration/510/4 "2015-11-17T18:49:19Z")

</div>

hi

I did use the host:port in the webhook and python server config. Its when I hit that endpoint that I got the errors that you see. The errors were generated when hitting it through a browser or triggering by using the reserved word in the channel.

My set up is Ubuntu 14.04. Python 2.7.6. Apache.

I also set the env vars in bash (and sourced it) and set them in the python script manually as well.

I am using an SSL config for apache. If I hit [https://host](https://host):port/new\_post the above error is produced.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![jwilander](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jwilander/32/8440_2.png) [@jwilander](https://forum.mattermost.com/u/jwilander)\
**Post date:** [November 20, 2015, 3:41pm UTC](https://forum.mattermost.com/t/giphy-integration/510/5 "2015-11-20T15:41:00Z")

</div>

If it’s failing on both the `https://host:port/new_post` and the `https://host:port/` endpoints then it looks like some sort of issue with Flask or Python requests.

It might be related to your use of SSL but if Apache’s handling it, then I’m not too sure what would be causing the issue. Are you able to temporarily disable SSL and test out the integration, for troubleshooting purposes?

I also checked the `requirements.txt` to see if it has the latest versions of Flask and Python Requests. Flask is latest at 0.10.1 but Requests is at 2.2.1 when the latest is 2.8.1. So you can try upgrading Requests to the latest version with `pip install requests==2.8.1`.

---

<div class="post-metadata">

**Author:** ![booksprint](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/booksprint/32/1636_2.png) [@booksprint](https://forum.mattermost.com/u/booksprint)\
**Post date:** [November 23, 2015, 9:18pm UTC](https://forum.mattermost.com/t/giphy-integration/510/6 "2015-11-23T21:18:54Z")

</div>

hi

Thanks for this - I have the same isues after trying requests 2.8.1

Interested to know if anyone else was able to get Giphy integration to work in Ubuntu.

---

<div class="post-metadata">

**Author:** ![kingfisher77](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/kingfisher77/32/172_2.png) [@kingfisher77](https://forum.mattermost.com/u/kingfisher77)\
**Post date:** [December 2, 2015, 5:06pm UTC](https://forum.mattermost.com/t/giphy-integration/510/7 "2015-12-02T17:06:36Z")

</div>

Hi, we configured everything exactly like you did, but we receive

`127.0.0.1 - - [02/Dec/2015 18:02:09] "POST / HTTP/1.1" 405 -`

in the [server.py](http://server.py) log.

Outgoing Hook:

```
URLs: http://localhost:8066
Trigger Words: gif:
Token: yndo4k4bify8uqsr7tp4puki9A

```

.bash\_profile:

export MATTERMOST\_TOKEN=yndo4k4bify8uqsr7tp4puki9A  
export PORT=8066

Some idea?

---

<div class="post-metadata">

**Author:** ![kingfisher77](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/kingfisher77/32/172_2.png) [@kingfisher77](https://forum.mattermost.com/u/kingfisher77)\
**Post date:** [December 2, 2015, 5:07pm UTC](https://forum.mattermost.com/t/giphy-integration/510/8 "2015-12-02T17:07:15Z")

</div>

http 405: method not allowed

---

<div class="post-metadata">

**Author:** ![kai23](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/kai23/32/773_2.png) [@kai23](https://forum.mattermost.com/u/kai23)\
**Post date:** [June 28, 2016, 2:46pm UTC](https://forum.mattermost.com/t/giphy-integration/510/9 "2016-06-28T14:46:21Z")

</div>

Hi ! I have this exact same issue. 405 not allowed. Any idea, someone?
