Swap out Flask's default web server for Waitress (#32)

* Ignore venv when building docker file

* Remove reference to 8888 port

It wasn't really used anywhere, and setting it to 5000 everywhere removes ambiguity, and makes things easier to track and reason about

* Use waitress rather than Flask's built in web server

It's not production grade

* Actually add waitress to requirements

Woops!
pull/36/head
Jake Howard 4 years ago committed by GitHub
parent 14a41a89b6
commit f700ed88e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1,2 @@
.git/
venv/

@ -76,7 +76,7 @@ Whoogle Search console runner
optional arguments:
-h, --help show this help message and exit
--port <port number> Specifies a port to run on (default 8888)
--port <port number> Specifies a port to run on (default 5000)
--host <ip address> Specifies the host address to use (default 127.0.0.1)
--debug Activates debug mode for the Flask server (default False)
```
@ -104,7 +104,7 @@ pip install -r requirements.txt
git clone https://github.com/benbusby/whoogle-search.git
cd whoogle-search
docker build --tag whooglesearch:1.0 .
docker run --publish 8888:5000 --detach --name whooglesearch whooglesearch:1.0
docker run --publish 5000:5000 --detach --name whooglesearch whooglesearch:1.0
```
And kill with: `docker rm --force whooglesearch`

@ -0,0 +1,3 @@
from .routes import run_app
run_app()

@ -9,6 +9,7 @@ import io
import json
import os
import urllib.parse as urlparse
import waitress
app.config['APP_ROOT'] = os.getenv('APP_ROOT', os.path.dirname(os.path.abspath(__file__)))
app.config['STATIC_FOLDER'] = os.getenv('STATIC_FOLDER', os.path.join(app.config['APP_ROOT'], 'static'))
@ -146,12 +147,14 @@ def window():
def run_app():
parser = argparse.ArgumentParser(description='Whoogle Search console runner')
parser.add_argument('--port', default=8888, metavar='<port number>',
help='Specifies a port to run on (default 8888)')
parser.add_argument('--port', default=5000, metavar='<port number>',
help='Specifies a port to run on (default 5000)')
parser.add_argument('--host', default='127.0.0.1', metavar='<ip address>',
help='Specifies the host address to use (default 127.0.0.1)')
parser.add_argument('--debug', default=False, action='store_true',
help='Activates debug mode for the Flask server (default False)')
help='Activates debug mode for the server (default False)')
args = parser.parse_args()
if args.debug:
app.run(host=args.host, port=args.port, debug=args.debug)
else:
waitress.serve(app, listen="{}:{}".format(args.host, args.port))

@ -5,5 +5,5 @@ services:
image: benbusby/whoogle-search
container_name: whoogle-search
ports:
- 8888:5000
- 5000:5000
restart: unless-stopped

@ -15,3 +15,4 @@ python-dateutil==2.8.1
six==1.14.0
soupsieve==1.9.5
Werkzeug==0.16.0
waitress==1.4.3

@ -17,11 +17,9 @@ export STATIC_FOLDER=$APP_ROOT/static
mkdir -p $STATIC_FOLDER
pkill flask
# Check for regular vs test run
if [[ $SUBDIR == "test" ]]; then
pytest -sv
else
flask run --host="0.0.0.0" --port=$PORT
python3 -m app --port $PORT
fi

Loading…
Cancel
Save