File tree Expand file tree Collapse file tree 5 files changed +29
-6
lines changed
Expand file tree Collapse file tree 5 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,15 @@ Python Flask WEB API DEMO
105105CORS(app, resources={r"/*": {"origins": "http://localhost:3000"}})
106106
107107
108+ ### REDIS CONFIG FOR SERVER-SIDE SESSION WITH FLASK SESSION :
109+ - Install, configure and secure Redis in your server : https://redis.io/
110+ - Add in your config.py file or prod-config.py file :
111+ import redis
112+ ...
113+ SESSION_TYPE = 'redis'
114+ SESSION_REDIS = redis.from_url('127.0.0.1:6379')
115+
116+
108117#### COMMON SQL SCRIPT ON DATABASE FROM MYSQL SERVER :
109118- Signin in first with `mysql -u root -p`
110119- Create a database : `CREATE DATABASE my_database;`
Original file line number Diff line number Diff line change 3939csrf = CSRFProtect (app )
4040
4141# REGISTER SESSION
42- Session (app )
43-
42+ # Session(app)
43+ sess = Session ()
44+ sess .init_app (app )
4445
4546# REGISTER LOGGING
4647logger = logging .getLogger (__name__ )
Original file line number Diff line number Diff line change 33
44# ------- IMPORT DEPENDENCIES -------
55import os
6+ import redis
67from datetime import timedelta
78
89# ------- IMPORT LOCAL DEPENDENCIES -------
@@ -70,12 +71,16 @@ class BaseConfig(object):
7071
7172 SESSION_PERMANENT = False
7273 # PERMANENT_SESSION_LIFETIME = 5 -> ISSUE : if resized to 5, you'll get csrf_token missing issue
73- PERMANENT_SESSION_LIFETIME = timedelta (seconds = 120 )
74+ PERMANENT_SESSION_LIFETIME = timedelta (minutes = 5 )
7475
7576 # SESSION_TYPE = 'sqlalchemy'
7677 # SESSION_SQLALCHEMY = None
7778 # SESSION_SQLALCHEMY_TABLE = 'sessions'
78-
79+
80+ # SESSION_TYPE = 'redis'
81+ # SESSION_REDIS = redis.from_url('127.0.0.1:6379')
82+
83+ # Tod do : fix issue : session file are not removed after the end of the session
7984 SESSION_TYPE = 'filesystem'
8085 SESSION_FILE_DIR = 'sessions'
8186 SESSION_FILE_THRESHOLD = 500
Original file line number Diff line number Diff line change 11alembic==0.9.1
22aniso8601==1.2.0
3+ appdirs==1.4.3
34asn1crypto==0.22.0
45astroid==1.4.9
56Babel==2.4.0
67backports-abc==0.5
78backports.functools-lru-cache==1.3
89backports.ssl-match-hostname==3.5.0.1
9- BeautifulSoup==3.2.1
1010bleach==2.0.0
1111blinker==1.4
1212boto==2.45.0
@@ -38,6 +38,7 @@ Flask-SQLAlchemy==2.1
3838Flask-Uploads==0.2.1
3939Flask-WTF==0.14.2
4040geocoder==1.22.4
41+ gunicorn==19.7.1
4142html5lib==0.999999999
4243humanize==0.5.1
4344idna==2.5
@@ -73,6 +74,7 @@ python-loaders==0.2.3
7374python-mimeparse==1.6.0
7475pytz==2016.10
7576ratelim==0.1.6
77+ redis==2.10.6
7678requests==2.13.0
7779sendgrid==3.6.3
7880setuptools==28.8.0
@@ -82,13 +84,15 @@ smtpapi==0.3.1
8284SQLAlchemy==1.1.5
8385stevedore==1.20.0
8486tornado==4.4.2
87+ uWSGI==2.0.15
8588virtualenv==15.1.0
8689virtualenv-clone==0.2.6
8790virtualenvwrapper==4.7.2
8891virtualenvwrapper-win==1.2.1
8992visitor==0.1.3
9093webencodings==0.5.1
9194Werkzeug==0.11.15
95+ wheel==0.29.0
9296wrapt==1.10.8
9397wtf==0.1
9498WTForms==2.1
Original file line number Diff line number Diff line change 11alembic (0.9.1)
22aniso8601 (1.2.0)
3+ appdirs (1.4.3)
34asn1crypto (0.22.0)
45astroid (1.4.9)
56Babel (2.4.0)
67backports-abc (0.5)
78backports.functools-lru-cache (1.3)
89backports.ssl-match-hostname (3.5.0.1)
9- BeautifulSoup (3.2.1)
1010bleach (2.0.0)
1111blinker (1.4)
1212boto (2.45.0)
@@ -38,6 +38,7 @@ Flask-SQLAlchemy (2.1)
3838Flask-Uploads (0.2.1)
3939Flask-WTF (0.14.2)
4040geocoder (1.22.4)
41+ gunicorn (19.7.1)
4142html5lib (0.999999999)
4243humanize (0.5.1)
4344idna (2.5)
@@ -73,6 +74,7 @@ python-loaders (0.2.3)
7374python-mimeparse (1.6.0)
7475pytz (2016.10)
7576ratelim (0.1.6)
77+ redis (2.10.6)
7678requests (2.13.0)
7779sendgrid (3.6.3)
7880setuptools (28.8.0)
@@ -82,13 +84,15 @@ smtpapi (0.3.1)
8284SQLAlchemy (1.1.5)
8385stevedore (1.20.0)
8486tornado (4.4.2)
87+ uWSGI (2.0.15)
8588virtualenv (15.1.0)
8689virtualenv-clone (0.2.6)
8790virtualenvwrapper (4.7.2)
8891virtualenvwrapper-win (1.2.1)
8992visitor (0.1.3)
9093webencodings (0.5.1)
9194Werkzeug (0.11.15)
95+ wheel (0.29.0)
9296wrapt (1.10.8)
9397wtf (0.1)
9498WTForms (2.1)
You can’t perform that action at this time.
0 commit comments