remotes/1693045480750635534/spooky-22
Aevann1 2021-08-13 22:49:34 +02:00
parent 4e6d150e7d
commit 2f23ff1db8
6 changed files with 47 additions and 12 deletions

View File

@ -16,7 +16,7 @@ services:
- SITE_NAME=Drama
- CLOUDFLARE_ZONE=vcxvdfgfc6r554etrgd
- CLOUDFLARE_KEY=vcxvdfgfc6r554etrgd
- TENOR_KEY=vcxvdfgfc6r554etrgd
- GIPHY_KEY=vcxvdfgfc6r554etrgd
- MAILGUN_KEY=vcxvdfgfc6r554etrgd
- MAILGUN_DOMAIN=rdrama.net
- FORCE_HTTPS=0

View File

@ -87,8 +87,6 @@ app.config["CACHE_OPTIONS"]={'connection_pool':redispool} if app.config["CACHE_T
app.config["READ_ONLY"]=bool(int(environ.get("READ_ONLY", "0")))
app.config["BOT_DISABLE"]=bool(int(environ.get("BOT_DISABLE", False)))
app.config["TENOR_KEY"]=environ.get("TENOR_KEY",'').strip()
Markdown(app)
cache = Cache(app)

View File

@ -0,0 +1,22 @@
from flask import *
from os import environ
import requests
from files.__main__ import app
GIPHY_KEY = environ.get('GIPHY_KEY').rstrip()
@app.route("/giphy", methods=["GET"])
@app.route("/giphy<path>", methods=["GET"])
def giphy():
searchTerm = request.args.get("searchTerm", "")
limit = int(request.args.get("limit", ""))
if searchTerm and limit:
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit={limit}"
elif searchTerm and not limit:
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48"
else:
url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48"
return jsonify(requests.get(url).json())

View File

@ -25,11 +25,4 @@
</div>
</div>
</div>
<script>
function tenor_api_key() {
return "{{'TENOR_KEY' | app_config}}"
}
</script>
</div>

22
giphy.py 100644
View File

@ -0,0 +1,22 @@
from flask import *
from os import environ
import requests
from files.__main__ import app
GIPHY_KEY = environ.get('GIPHY_KEY').rstrip()
@app.route("/giphy", methods=["GET"])
@app.route("/giphy<path>", methods=["GET"])
def giphy():
searchTerm = request.args.get("searchTerm", "")
limit = int(request.args.get("limit", ""))
if searchTerm and limit:
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit={limit}"
elif searchTerm and not limit:
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48"
else:
url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48"
return jsonify(requests.get(url).json())

View File

@ -24,7 +24,7 @@ docker-compose up
4- That's it! Visit `localhost` in your browser.
5- Optional: to configure the site settings and successsfully integrate it with the external services we use (hcaptcha, cloudflare, discord, tenor and mailgun), please edit the variables in the docker-compose.yml file.
5- Optional: to configure the site settings and successsfully integrate it with the external services we use (hcaptcha, cloudflare, discord, giphy and mailgun), please edit the variables in the docker-compose.yml file.
---
@ -51,7 +51,7 @@ source setup
4- That's it. Visit `localhost` in your browser.
5- Optional: to configure the site settings and successsfully integrate it with the external services we use (hcaptcha, cloudflare, discord, tenor and mailgun), please run this command and edit the variables:
5- Optional: to configure the site settings and successsfully integrate it with the external services we use (hcaptcha, cloudflare, discord, giphy and mailgun), please run this command and edit the variables:
```
nano /drama/docker-compose.yml