|
1 | | -# tutorial-sms-flask-python-sdk |
| 1 | +# How to Send SMS Messages with Python, Flask, and Vonage |
| 2 | + |
| 3 | +Using content in this repository, you can send an SMS using the Flask application and Vonage API. Prepared a simple code sample will be an excellent point to start and create your application quickly. |
| 4 | + |
| 5 | +## Requirements |
| 6 | + |
| 7 | +* [Python](https://www.python.org/downloads/) |
| 8 | +* [GIT](https://git-scm.com/downloads) |
| 9 | +* [Vonage Application](https://developer.vonage.com/application/overview) |
| 10 | + |
| 11 | +Sign in/Sign up for free [developer.vonage.com](https://developer.vonage.com/); to be able to use the [Vonage Messages API](https://developer.vonage.com/en/messages/overview), you'll have to create a [Vonage Application](https://developer.vonage.com/application/overview) from the developer portal. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +In the left menu [here](https://dashboard.nexmo.com/), click API Settings. Under the API keys tab, you will find your API key and Account secret (API secret). We will use these credentials later. |
| 16 | + |
| 17 | +**Set up a Python** |
| 18 | + |
| 19 | +First, make sure that your laptop/server has [Python 3](https://www.python.org/downloads/) installed. We will then use venv to create an isolated environment with only the necessary packages. |
| 20 | + |
| 21 | +To deploy the application, you need to clone the repo using [git](https://git-scm.com/downloads) and update `.env` with your credentials |
| 22 | + |
| 23 | +## Installation |
| 24 | + |
| 25 | +Clone source code |
| 26 | +```bash |
| 27 | +git clone https://github.com/obvonage/tutorial-sms-flask-python-sdk |
| 28 | +``` |
| 29 | + |
| 30 | +Go to the project folder |
| 31 | +```bash |
| 32 | +cd tutorial-sms-flask-python-sdk |
| 33 | +``` |
| 34 | + |
| 35 | +Install dependencies |
| 36 | + |
| 37 | +```bash |
| 38 | +pip install -r requirements.txt |
| 39 | +``` |
| 40 | + |
| 41 | +Start your app with the following command. |
| 42 | + |
| 43 | +```bash |
| 44 | +FLASK_APP=server.py flask run |
| 45 | +``` |
| 46 | +Expected output |
| 47 | +```bash |
| 48 | + * Serving Flask app 'server.py' |
| 49 | + * Debug mode: on |
| 50 | +WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. |
| 51 | + * Running on http://127.0.0.1:5000 |
| 52 | +Press CTRL+C to quit |
| 53 | + * Restarting with stat |
| 54 | + * Debugger is active! |
| 55 | + * Debugger PIN: 648-303-150 |
| 56 | + |
| 57 | +``` |
| 58 | +## Usage |
| 59 | + |
| 60 | +Open [http://localhost:5000/](http://localhost:5000/) in your browser, and you should see the following web page |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +Let's send an SMS using this interface. Ensure the number is in international format without the '+' at the start. Hit "Send SMS" and check your phone! |
0 commit comments