Allow setting environment variables in whoogle.env (#237)
This allows the user to enable their preferred settings in a variety of ways, depending on their deployment preference. Values added to whoogle.env can be enabled using WHOOGLE_DOTENV=1, in which case all values in the env var file will overwrite defaults or user provided settings. Co-authored-by: Ben Busby <benbusby@protonmail.com>main
parent
b2416394ff
commit
8a10efaa01
|
@ -37,6 +37,9 @@ ENV WHOOGLE_PROXY_TYPE=$proxytype
|
||||||
ARG proxyloc=''
|
ARG proxyloc=''
|
||||||
ENV WHOOGLE_PROXY_LOC=$proxyloc
|
ENV WHOOGLE_PROXY_LOC=$proxyloc
|
||||||
|
|
||||||
|
ARG whoogle_dotenv=''
|
||||||
|
ENV WHOOGLE_DOTENV=$whoogle_dotenv
|
||||||
|
|
||||||
ARG use_https=''
|
ARG use_https=''
|
||||||
ENV HTTPS_ONLY=$use_https
|
ENV HTTPS_ONLY=$use_https
|
||||||
|
|
||||||
|
@ -59,6 +62,7 @@ COPY misc/tor/torrc /etc/tor/torrc
|
||||||
COPY misc/tor/start-tor.sh misc/tor/start-tor.sh
|
COPY misc/tor/start-tor.sh misc/tor/start-tor.sh
|
||||||
COPY app/ app/
|
COPY app/ app/
|
||||||
COPY run .
|
COPY run .
|
||||||
|
COPY whoogle.env .
|
||||||
|
|
||||||
EXPOSE $EXPOSE_PORT
|
EXPOSE $EXPOSE_PORT
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,8 @@ Description=Whoogle
|
||||||
#Environment=WHOOGLE_ALT_YT=invidious.snopyta.org
|
#Environment=WHOOGLE_ALT_YT=invidious.snopyta.org
|
||||||
#Environment=WHOOGLE_ALT_IG=bibliogram.art/u
|
#Environment=WHOOGLE_ALT_IG=bibliogram.art/u
|
||||||
#Environment=WHOOGLE_ALT_RD=libredd.it
|
#Environment=WHOOGLE_ALT_RD=libredd.it
|
||||||
|
# Load values from dotenv only
|
||||||
|
#Environment=WHOOGLE_DOTENV=1
|
||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=<whoogle_directory>
|
WorkingDirectory=<whoogle_directory>
|
||||||
|
@ -233,10 +235,11 @@ Depending on your preferences, you can also deploy the app yourself on your own
|
||||||
- A bit more experience or willingness to work through issues
|
- A bit more experience or willingness to work through issues
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
There are a few optional environment variables available for customizing a Whoogle instance:
|
There are a few optional environment variables available for customizing a Whoogle instance. These can be set manually, or copied into `whoogle.env` and enabled by setting `WHOOGLE_DOTENV=1`.
|
||||||
|
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
| ------------------ | -------------------------------------------------------------- |
|
| ------------------ | -------------------------------------------------------------- |
|
||||||
|
| WHOOGLE_DOTENV | Load environment variables in `whoogle.env` |
|
||||||
| WHOOGLE_USER | The username for basic auth. WHOOGLE_PASS must also be set if used. |
|
| WHOOGLE_USER | The username for basic auth. WHOOGLE_PASS must also be set if used. |
|
||||||
| WHOOGLE_PASS | The password for basic auth. WHOOGLE_USER must also be set if used. |
|
| WHOOGLE_PASS | The password for basic auth. WHOOGLE_USER must also be set if used. |
|
||||||
| WHOOGLE_PROXY_USER | The username of the proxy server. |
|
| WHOOGLE_PROXY_USER | The username of the proxy server. |
|
||||||
|
|
|
@ -6,9 +6,17 @@ from flask_session import Session
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from stem import Signal
|
from stem import Signal
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
app = Flask(__name__, static_folder=os.path.dirname(
|
app = Flask(__name__, static_folder=os.path.dirname(
|
||||||
os.path.abspath(__file__)) + '/static')
|
os.path.abspath(__file__)) + '/static')
|
||||||
|
|
||||||
|
# Load .env file if enabled
|
||||||
|
if os.getenv("WHOOGLE_DOTENV", ''):
|
||||||
|
dotenv_path = '../whoogle.env'
|
||||||
|
load_dotenv(os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||||
|
dotenv_path))
|
||||||
|
|
||||||
app.user_elements = {}
|
app.user_elements = {}
|
||||||
app.default_key_set = generate_user_keys()
|
app.default_key_set = generate_user_keys()
|
||||||
app.no_cookie_ips = []
|
app.no_cookie_ips = []
|
||||||
|
|
|
@ -3,6 +3,7 @@ import os
|
||||||
import urllib.parse as urlparse
|
import urllib.parse as urlparse
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
|
|
||||||
|
|
||||||
SKIP_ARGS = ['ref_src', 'utm']
|
SKIP_ARGS = ['ref_src', 'utm']
|
||||||
SKIP_PREFIX = ['//www.', '//mobile.', '//m.']
|
SKIP_PREFIX = ['//www.', '//mobile.', '//m.']
|
||||||
GOOG_STATIC = 'www.gstatic.com'
|
GOOG_STATIC = 'www.gstatic.com'
|
||||||
|
@ -12,6 +13,7 @@ BLANK_B64 = ('data:image/png;base64,'
|
||||||
'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAD0lEQVR42mNkw'
|
'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAD0lEQVR42mNkw'
|
||||||
'AIYh7IgAAVVAAuInjI5AAAAAElFTkSuQmCC')
|
'AIYh7IgAAVVAAuInjI5AAAAAElFTkSuQmCC')
|
||||||
|
|
||||||
|
|
||||||
# Ad keywords
|
# Ad keywords
|
||||||
BLACKLIST = [
|
BLACKLIST = [
|
||||||
'ad', 'anuncio', 'annuncio', 'annonce', 'Anzeige', '广告', '廣告', 'Reklama',
|
'ad', 'anuncio', 'annuncio', 'annonce', 'Anzeige', '广告', '廣告', 'Reklama',
|
||||||
|
@ -70,6 +72,7 @@ def get_site_alt(link: str) -> str:
|
||||||
str: An updated (or ignored) result link
|
str: An updated (or ignored) result link
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for site_key in SITE_ALTS.keys():
|
for site_key in SITE_ALTS.keys():
|
||||||
if site_key not in link:
|
if site_key not in link:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -37,6 +37,8 @@ services:
|
||||||
#- WHOOGLE_ALT_YT=invidious.snopyta.org
|
#- WHOOGLE_ALT_YT=invidious.snopyta.org
|
||||||
#- WHOOGLE_ALT_IG=bibliogram.art/u
|
#- WHOOGLE_ALT_IG=bibliogram.art/u
|
||||||
#- WHOOGLE_ALT_RD=libredd.it
|
#- WHOOGLE_ALT_RD=libredd.it
|
||||||
|
# Load environment variables from whoogle.env
|
||||||
|
#- WHOOGLE_DOTENV=1
|
||||||
ports:
|
ports:
|
||||||
- 5000:5000
|
- 5000:5000
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
|
@ -31,3 +31,4 @@ urllib3==1.25.9
|
||||||
waitress==1.4.3
|
waitress==1.4.3
|
||||||
wcwidth==0.1.9
|
wcwidth==0.1.9
|
||||||
Werkzeug==0.16.0
|
Werkzeug==0.16.0
|
||||||
|
python-dotenv==0.16.0
|
||||||
|
|
2
run
2
run
|
@ -22,5 +22,5 @@ else
|
||||||
mkdir -p "$STATIC_FOLDER"
|
mkdir -p "$STATIC_FOLDER"
|
||||||
python3 -um app \
|
python3 -um app \
|
||||||
--host "${ADDRESS:-0.0.0.0}" \
|
--host "${ADDRESS:-0.0.0.0}" \
|
||||||
--port "${PORT:-"${EXPOSE_PORT:-5000}"}"
|
--port "${PORT:-"${EXPOSE_PORT:-5000}"}" --debug
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
# You can set Whoogle environment variables here, but must set
|
||||||
|
# WHOOGLE_DOTENV=1 in your deployment to enable these values
|
||||||
|
|
||||||
|
#WHOOGLE_ALT_TW=nitter.net
|
||||||
|
#WHOOGLE_ALT_YT=invidious.snopyta.org
|
||||||
|
#WHOOGLE_ALT_IG=bibliogram.art/u
|
||||||
|
#WHOOGLE_ALT_RD=libredd.it
|
||||||
|
#WHOOGLE_USER=""
|
||||||
|
#WHOOGLE_PASS=""
|
||||||
|
#WHOOGLE_PROXY_USER=""
|
||||||
|
#WHOOGLE_PROXY_PASS=""
|
||||||
|
#WHOOGLE_PROXY_TYPE=""
|
||||||
|
#WHOOGLE_PROXY_LOC=""
|
||||||
|
#HTTPS_ONLY=1
|
Loading…
Reference in New Issue