Friday, March 31, 2017

My first sms project using TWILIO , PYTHON and DOCKER

I just found out this cool app called twilio and I really interested how it works. My main objective is to create a mass sms sending app but its too far at this point.

First, I found this youtube from cleverprogramming website. https://www.youtube.com/watch?v=uzBRycRYsqw. The tutorial is very straight forward. I can follow his steps but I want something different in my setup. I want to use docker instead installing in my development pc which I'm working in the office now. Hopefully no ones knows what I'm doing. haha

But anyway, so first I'm struggling how to mount the volume from my python image. So this is what I did.

1. run docker pull python
this will pull the latest images which i think python 3.6

2. create a dockerfile
FROM python
RUN pip install twilio
VOLUME ["/mnt/python_file"]

from script above, I creating a python base image and install twilio app and specify the volume. Isn't that easy. But the hardest part, is that I don't know if its working exactly what I wanted.

3. run docker build -t python-twilio

i have already my custom image, next will run this to create a container.

4. run docker run -v /c/Users/DEFAULT.DEFAULT-PC/volumes:/mnt/python_file python-twilio python /mnt/python_file/send_sms.py

previously, i didn't add '/mnt/python_files/' from send_sms.py which giving me error that the file is not found. So that's it, i received the sms message to my phone, Eureka!

btw, I have so much to improve my code. we will see next time to achieve my goal to build an app. Viola!



UPDATED:
The new command below is changing the volume from c: drive to d:.
d_drive name is the same which I configure in the Oracle VM virtualbox.

ex1:
docker run -v /d_drive/Lynard/development/personal/twilio_tutorial:/mnt/python_file twilio1 python /mnt/python_file/send_sms.py

ex2:
docker run -v /d_drive/Lynard/development/personal/twilio_tutorial:/mnt/codes ls/twilio python /mnt/codes/send_sms.py

So now, I can do and save my code in my drive D: isn't that great! Eureka!!!!

No comments:

Post a Comment

free online comma separating tool

https://delim.co/#