Skip to content

Commit

Permalink
Added notes on setting up on EC2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Apr 2, 2021
1 parent b2240dc commit 7ab0480
Show file tree
Hide file tree
Showing 647 changed files with 25 additions and 103,232 deletions.
6 changes: 6 additions & 0 deletions Notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To set up a production WSGI server: https://towardsdatascience.com/deploying-flask-with-gunicorn-3-9eaacd0f6eea
Application Server vs. Web Server
Seems that an application server processes dynamic content, and a web server serves up static content. This can be done very quickly since the web server is a worker model.
If you want authentication on the static files -> https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/

Great Read on setting up flask/nginx on EC2 -> https://medium.com/@varunchitale/a-simple-python-api-using-flask-with-nginx-setup-on-aws-ec2-4a380ceaf006
4 changes: 2 additions & 2 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import timeit

app = flask.Flask(__name__)
app.config["DEBUG"] = True
app.config["DEBUG"] = False

# https://programminghistorian.org/en/lessons/creating-apis-with-python-and-flask
# Add weather data for our catalog
Expand Down Expand Up @@ -77,4 +77,4 @@ def upload_file():
return "File Saved"


app.run()
app.run(host="0.0.0.0", port=5000)
4 changes: 2 additions & 2 deletions env/bin/activate
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ deactivate () {
fi

unset VIRTUAL_ENV
if [ ! "$1" = "nondestructive" ] ; then
if [ ! "${1:-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
Expand All @@ -37,7 +37,7 @@ deactivate () {
# unset irrelevant variables
deactivate nondestructive

VIRTUAL_ENV="/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env"
VIRTUAL_ENV="/home/ubuntu/secure-python-flask-api/env"
export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
Expand Down
2 changes: 1 addition & 1 deletion env/bin/activate.csh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PA
# Unset irrelevant variables.
deactivate nondestructive

setenv VIRTUAL_ENV "/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env"
setenv VIRTUAL_ENV "/home/ubuntu/secure-python-flask-api/env"

set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
Expand Down
4 changes: 2 additions & 2 deletions env/bin/activate.fish
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ end
# unset irrelevant variables
deactivate nondestructive

set -gx VIRTUAL_ENV "/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env"
set -gx VIRTUAL_ENV "/home/ubuntu/secure-python-flask-api/env"

set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
Expand All @@ -52,7 +52,7 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
set -l old_status $status

# Prompt override?
if test -n "(env) "
if test -n "(env) "
printf "%s%s" "(env) " (set_color normal)
else
# ...Otherwise, prepend env
Expand Down
7 changes: 2 additions & 5 deletions env/bin/easy_install
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env/bin/python3

#!/home/ubuntu/secure-python-flask-api/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from setuptools.command.easy_install import main

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
11 changes: 0 additions & 11 deletions env/bin/easy_install-3.6

This file was deleted.

7 changes: 2 additions & 5 deletions env/bin/flask
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env/bin/python3

#!/home/ubuntu/secure-python-flask-api/env/bin/python
# -*- coding: utf-8 -*-
import re
import sys

from flask.cli import main

if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
9 changes: 3 additions & 6 deletions env/bin/pip
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env/bin/python3

#!/home/ubuntu/secure-python-flask-api/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from pip import main

from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
9 changes: 3 additions & 6 deletions env/bin/pip3
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env/bin/python3

#!/home/ubuntu/secure-python-flask-api/env/bin/python3
# -*- coding: utf-8 -*-
import re
import sys

from pip import main

from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
11 changes: 0 additions & 11 deletions env/bin/pip3.6

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/LICENSE.rst

This file was deleted.

137 changes: 0 additions & 137 deletions env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/METADATA

This file was deleted.

48 changes: 0 additions & 48 deletions env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/RECORD

This file was deleted.

6 changes: 0 additions & 6 deletions env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/WHEEL

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7ab0480

Please sign in to comment.