Skip to content

Commit

Permalink
Fixed Docker + added debug option to Flask
Browse files Browse the repository at this point in the history
  • Loading branch information
blabla1337 committed Jul 10, 2017
1 parent 28d087e commit 042d780
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -30,7 +30,7 @@ install:
before_script:
- cd ../
- export PYTHONWARNINGS="ignore"
- export FLASK_DEBUG=True
- export FLASK_DEBUG=1
- export FLASK_APP=skf/app.py
- export PYTHONPATH=.:$PYTHONPATH

Expand Down
2 changes: 1 addition & 1 deletion Angular/src/app/project-list/project-list.component.ts
Expand Up @@ -44,6 +44,6 @@ export class ProjectListComponent implements OnInit {
}

open(content) {
this.modalService.open(content).result
this.modalService.open(content, { size: 'lg' }).result
}
}
Expand Up @@ -27,6 +27,7 @@ export class ProjectSummaryAuditComponent implements OnInit {
public error: string;
public succes: string;
public selector: string = "Development";
public showMe: string;

ngOnInit() {
this.route.params.subscribe(params => {
Expand Down Expand Up @@ -64,6 +65,7 @@ export class ProjectSummaryAuditComponent implements OnInit {
this.error = "";
this.succes = "";
this.comment = "";
this.showMe = checklistId;
this.route.params.subscribe(params => {
this.commentService.getComment(checklistId, params['id']).subscribe(
(data) => {
Expand Down
16 changes: 16 additions & 0 deletions Docker/alpine/entrypoint.sh
Expand Up @@ -3,6 +3,8 @@
set -x

HTTPS=${HTTPS:-'true'}
JWT_SECRET=${JWT_SECRET:-''}
ORIGIN=${ORIGIN:-'localhost'}

# Creation of certificates
if [[ "$HTTPS" == "true" ]]; then
Expand All @@ -28,6 +30,20 @@ else
PORT=80
fi

if [[ "$JWT_SECRET" != "" ]]; then
perl -pi -e "s/JWT_SECRET = ''/JWT_SECRET = '$JWT_SECRET'/" /skf-flask/skf/settings.py
else
echo 'You need to select a JWT_SECRET'
exit
fi

if [[ "$ORIGIN" != "" ]]; then
perl -pi -e "s/\*/https:\/\/$ORIGIN/" /skf-flask/skf/settings.py
else
echo 'You need to select a ORIGIN location'
exit
fi

# Create Nginx dir
mkdir /run/nginx

Expand Down
1 change: 1 addition & 0 deletions Docker/alpine/skf-api.sh
Expand Up @@ -4,4 +4,5 @@
cd /skf-flask
export FLASK_APP=skf/app.py
export PYTHONPATH=/skf-flask
export FLASK_DEBUG=True
python3.6 skf/app.py
21 changes: 0 additions & 21 deletions Docker/ubuntu/Dockerfile

This file was deleted.

3 changes: 2 additions & 1 deletion development
Expand Up @@ -2,13 +2,14 @@

export FLASK_APP=skf/app.py
export PYTHONPATH=.:$PYTHONPATH
export FLASK_DEBUG=1

while :
do
case "$(ps x |grep -v grep |grep -c "Python skf")" in

0) echo "Restarting skf:"
python3.6 skf/app.py
python3.6 skf/app.py
;;
2) echo "SKF already running"
;;
Expand Down
6 changes: 3 additions & 3 deletions skf/api/security.py
Expand Up @@ -60,10 +60,10 @@ def val_alpha_num(value):


def val_alpha_num_special(value):
"""User input validation for checking a-z A-Z 0-9 _ . - ' " """
match = re.findall(r"[^ a-zA-Z0-9_.-.'.\"]", value)
"""User input validation for checking a-z A-Z 0-9 _ . - ' , " """
match = re.findall(r"[^ a-zA-Z0-9_.-.'.\".,]", value)
if match:
log("User supplied not an a-z A-Z 0-9 _ . - ' \" value", "MEDIUM", "FAIL")
log("User supplied not an a-z A-Z 0-9 _ . - ' \" , value", "MEDIUM", "FAIL")
abort(400, "Validation Error")
else:
return True
Expand Down
10 changes: 5 additions & 5 deletions skf/app.py
Expand Up @@ -66,7 +66,7 @@

app = Flask(__name__)
# TO DO FIX WILDCARD ONLY ALLOW NOW FOR DEV
cors = CORS(app, resources={r"/*": {"origins": "*"}})
cors = CORS(app, resources={r"/*": {"origins": settings.ORIGINS}})
logging.config.fileConfig('logging.conf')
log = logging.getLogger(__name__)

Expand All @@ -82,8 +82,8 @@ def configure_app(flask_app):
flask_app.config['RESTPLUS_MASK_SWAGGER'] = settings.RESTPLUS_MASK_SWAGGER
flask_app.config['ERROR_404_HELP'] = settings.RESTPLUS_ERROR_404_HELP
flask_app.config['TESTING'] = settings.TESTING
flask_app.config['DEBUG'] = settings.FLASK_DEBUG
flask_app.config['FLASK_DEBUG'] = settings.FLASK_DEBUG


def initialize_app(flask_app):
"""Initialize the SKF app."""
Expand Down Expand Up @@ -121,11 +121,11 @@ def main():
log.info('>>>>> Configure the JWT_SECRET in the settings.py file and choose an unique 128 character long secret <<<<<')
else:
log.info('>>>>> Starting development server http://'+settings.FLASK_HOST+":"+str(settings.FLASK_PORT)+' <<<<<')
app.run(host=settings.FLASK_HOST, port=settings.FLASK_PORT, debug=settings.FLASK_DEBUG)
app.run(host=settings.FLASK_HOST, port=settings.FLASK_PORT, debug=app.debug)
if app.debug == True:
if settings.JWT_SECRET == '':
log.info('>>>>> Starting development server http://'+settings.FLASK_HOST+":"+str(settings.FLASK_PORT)+' <<<<<')
app.run(host=settings.FLASK_HOST, port=settings.FLASK_PORT, debug=settings.FLASK_DEBUG)
app.run(host=settings.FLASK_HOST, port=settings.FLASK_PORT, debug=app.debug)


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions skf/settings.py
Expand Up @@ -18,6 +18,7 @@

# JWT settings
JWT_SECRET = ''
ORIGINS = '*'

# TESTING settings
TESTING = False

0 comments on commit 042d780

Please sign in to comment.