diff --git a/.gitignore b/.gitignore index b22bff2..01e1512 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ wheels/ .installed.cfg *.egg MANIFEST +Pipfile* # PyInstaller # Usually these files are written by a python script from a template @@ -103,3 +104,5 @@ venv.bak/ # mypy .mypy_cache/ .idea + +secrets.py diff --git a/README.md b/README.md index b43cfc1..4a101ba 100644 --- a/README.md +++ b/README.md @@ -6,24 +6,12 @@ As members of the Python guild, you will be working through the challenges of Tw We assume that before you begin, you will have [Python](http://www.python.org/) and [pip](http://www.pip-installer.org/en/latest/) installed on your system and available at the command line. -Before you can run this project, you will need to set three system environment variables. These are: +Before you can run this project, you will need to make a copy of secrets.py.example and name it secrets.py. Edit secrets.py and change the string values as follows, and then save the file: * `TWILIO_ACCOUNT_SID` : [Get it from your Twilio Console](https://www.twilio.com/console). * `TWILIO_AUTH_TOKEN` : Same as above. * `TWILIO_PHONE_NUMBER` : A Twilio number that you own, that can be used for making calls and sending messages. You can find a list of phone numbers you control (and buy another one, if necessary) [in the console](https://www.twilio.com/console/phone-numbers/incoming). -For Mac and Linux, environment variables can be set by opening a terminal window and typing the following three commands - replace all the characters after the `=` with values from your Twilio account: -``` - export TWILIO_ACCOUNT_SID=ACXXXXXXXXX - export TWILIO_AUTH_TOKEN=XXXXXXXXX - export TWILIO_PHONE_NUMBER=+16518675309 -``` -On Windows, the easiest way to set permanent environment variables (as of Windows 8) is using the `setx` command. Note that there is no `=`, just the key and value separated by a space: -``` - setx TWILIO_ACCOUNT_SID ACXXXXXXXXX - setx TWILIO_AUTH_TOKEN XXXXXXXXX - setx TWILIO_PHONE_NUMBER +16518675309 -``` ## Running the application 1. Clone this repository. Navigate to the folder with the source code on your machine in a terminal window. diff --git a/app.py b/app.py index 66469aa..6744938 100644 --- a/app.py +++ b/app.py @@ -5,9 +5,13 @@ from twilio.rest import Client # Pull in configuration from system environment variables -TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID') -TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN') -TWILIO_PHONE_NUMBER = os.environ.get('TWILIO_PHONE_NUMBER') +#TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID') +#TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN') +#TWILIO_PHONE_NUMBER = os.environ.get('TWILIO_PHONE_NUMBER') +try: + from secrets import TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, TWILIO_PHONE_NUMBER +except ImportError: + print("Please create a secrets.py that looks like secrets.py.example") # create an authenticated client that can make requests to Twilio for your # account. diff --git a/secrets.py.example b/secrets.py.example new file mode 100644 index 0000000..c98b788 --- /dev/null +++ b/secrets.py.example @@ -0,0 +1,3 @@ +TWILIO_ACCOUNT_SID="ACXXXXXXXXX" +TWILIO_AUTH_TOKEN="XXXXXXXXX" +TWILIO_PHONE_NUMBER="+16518675309"