Added environment variables
This commit is contained in:
18
README.md
18
README.md
@@ -32,17 +32,19 @@ Visit the below URL to view the flask app:
|
||||
|
||||
If you do not have a dedicated server, I highly recommend using [Linode](https://www.linode.com/), [Heroku](https://www.heroku.com/) or [PythonAnywhere](https://www.pythonanywhere.com/) to host your application.
|
||||
|
||||
Before deploying, in the file:
|
||||
Before deploying, make sure to set the following environment variables:
|
||||
|
||||
tiny0/run.py
|
||||
$ export WEBSITE_DOMAIN=
|
||||
$ export SECRET_KEY=
|
||||
$ export DEBUG=
|
||||
$ export SQLALCHEMY_DATABASE_URI=
|
||||
|
||||
set running in debug mode to False:
|
||||
If not they will default to the following values:
|
||||
|
||||
app.run(debug=False)
|
||||
|
||||
and change the config file located in the directory below:
|
||||
|
||||
tiny0/tiny0/config.json
|
||||
WEBSITE_DOMAIN=127.0.0.1:5000
|
||||
SECRET_KEY=SECRET_KEY
|
||||
DEBUG=true
|
||||
SQLALCHEMY_DATABASE_URI=sqlite:///database.db
|
||||
|
||||
# License
|
||||
|
||||
|
||||
3
run.py
3
run.py
@@ -1,4 +1,5 @@
|
||||
from tiny0 import app
|
||||
from tiny0.config import DEBUG
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
app.run(debug=DEBUG)
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"WEBSITE_DOMAIN":"127.0.0.1:5000",
|
||||
"SECRET_KEY": "SECRET_KEY",
|
||||
"SQLALCHEMY_DATABASE_URI": "sqlite:///database.db"
|
||||
}
|
||||
@@ -1,9 +1,20 @@
|
||||
import json
|
||||
import os
|
||||
from distutils.util import strtobool
|
||||
|
||||
with open("tiny0/config.json", "r") as config_file:
|
||||
WEBSITE_DOMAIN = os.environ.get("WEBSITE_DOMAIN")
|
||||
if not WEBSITE_DOMAIN:
|
||||
WEBSITE_DOMAIN = "127.0.0.1:5000"
|
||||
|
||||
config_data = json.load(config_file)
|
||||
SECRET_KEY = os.environ.get("SECRET_KEY")
|
||||
if not SECRET_KEY:
|
||||
SECRET_KEY = "SECRET_KEY"
|
||||
|
||||
WEBSITE_DOMAIN = config_data.get("WEBSITE_DOMAIN")
|
||||
SECRET_KEY = config_data.get("SECRET_KEY")
|
||||
SQLALCHEMY_DATABASE_URI = config_data.get("SQLALCHEMY_DATABASE_URI")
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI")
|
||||
if not SQLALCHEMY_DATABASE_URI:
|
||||
SQLALCHEMY_DATABASE_URI = "sqlite:///database.db"
|
||||
|
||||
DEBUG = os.environ.get("DEBUG")
|
||||
if not DEBUG:
|
||||
DEBUG = "true"
|
||||
|
||||
DEBUG = strtobool(DEBUG)
|
||||
|
||||
Reference in New Issue
Block a user