Skip to content

Commit 7ab0480

Browse files
author
Ubuntu
committed
Added notes on setting up on EC2
1 parent b2240dc commit 7ab0480

File tree

647 files changed

+25
-103232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

647 files changed

+25
-103232
lines changed

Notes.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
To set up a production WSGI server: https://towardsdatascience.com/deploying-flask-with-gunicorn-3-9eaacd0f6eea
2+
Application Server vs. Web Server
3+
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.
4+
If you want authentication on the static files -> https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/
5+
6+
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

api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import timeit
66

77
app = flask.Flask(__name__)
8-
app.config["DEBUG"] = True
8+
app.config["DEBUG"] = False
99

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

7979

80-
app.run()
80+
app.run(host="0.0.0.0", port=5000)

env/bin/activate

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ deactivate () {
2828
fi
2929

3030
unset VIRTUAL_ENV
31-
if [ ! "$1" = "nondestructive" ] ; then
31+
if [ ! "${1:-}" = "nondestructive" ] ; then
3232
# Self destruct!
3333
unset -f deactivate
3434
fi
@@ -37,7 +37,7 @@ deactivate () {
3737
# unset irrelevant variables
3838
deactivate nondestructive
3939

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

4343
_OLD_VIRTUAL_PATH="$PATH"

env/bin/activate.csh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PA
88
# Unset irrelevant variables.
99
deactivate nondestructive
1010

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

1313
set _OLD_VIRTUAL_PATH="$PATH"
1414
setenv PATH "$VIRTUAL_ENV/bin:$PATH"

env/bin/activate.fish

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929
# unset irrelevant variables
3030
deactivate nondestructive
3131

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

3434
set -gx _OLD_VIRTUAL_PATH $PATH
3535
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
@@ -52,7 +52,7 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
5252
set -l old_status $status
5353

5454
# Prompt override?
55-
if test -n "(env) "
55+
if test -n "(env) "
5656
printf "%s%s" "(env) " (set_color normal)
5757
else
5858
# ...Otherwise, prepend env

env/bin/easy_install

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
#!/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env/bin/python3
2-
1+
#!/home/ubuntu/secure-python-flask-api/env/bin/python3
32
# -*- coding: utf-8 -*-
43
import re
54
import sys
6-
75
from setuptools.command.easy_install import main
8-
96
if __name__ == '__main__':
10-
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
7+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
118
sys.exit(main())

env/bin/easy_install-3.6

Lines changed: 0 additions & 11 deletions
This file was deleted.

env/bin/flask

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
#!/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env/bin/python3
2-
1+
#!/home/ubuntu/secure-python-flask-api/env/bin/python
32
# -*- coding: utf-8 -*-
43
import re
54
import sys
6-
75
from flask.cli import main
8-
96
if __name__ == '__main__':
10-
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
7+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
118
sys.exit(main())

env/bin/pip

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
#!/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env/bin/python3
2-
1+
#!/home/ubuntu/secure-python-flask-api/env/bin/python3
32
# -*- coding: utf-8 -*-
43
import re
54
import sys
6-
7-
from pip import main
8-
5+
from pip._internal.cli.main import main
96
if __name__ == '__main__':
10-
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
7+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
118
sys.exit(main())

env/bin/pip3

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
#!/home/phillip/Documents/Personal_Projects/secure-python-flask-api/env/bin/python3
2-
1+
#!/home/ubuntu/secure-python-flask-api/env/bin/python3
32
# -*- coding: utf-8 -*-
43
import re
54
import sys
6-
7-
from pip import main
8-
5+
from pip._internal.cli.main import main
96
if __name__ == '__main__':
10-
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
7+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
118
sys.exit(main())

env/bin/pip3.6

Lines changed: 0 additions & 11 deletions
This file was deleted.

env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/INSTALLER

Lines changed: 0 additions & 1 deletion
This file was deleted.

env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/LICENSE.rst

Lines changed: 0 additions & 28 deletions
This file was deleted.

env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/METADATA

Lines changed: 0 additions & 137 deletions
This file was deleted.

env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/RECORD

Lines changed: 0 additions & 48 deletions
This file was deleted.

env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/WHEEL

Lines changed: 0 additions & 6 deletions
This file was deleted.

env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/entry_points.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

env/lib/python3.6/site-packages/Flask-1.1.2.dist-info/top_level.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

env/lib/python3.6/site-packages/Jinja2-2.11.3.dist-info/INSTALLER

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)