Giter Club home page Giter Club logo

eta-notifications-flask's Introduction

ETA Notifications for Python - Flask

ETA notifications implementation with Python - Flask and Twilio.

Local development

This project is built using the Flask web framework. It runs on Python 2.7+ and Python 3.4+.

To run the app locally, first clone this repository and cd into its directory. Then:

  1. Create and activate a new python3 virtual environment.

    python3 -m venv venv
    source venv/bin/activate
  2. Install the requirements:

    pip install -r requirements.txt
  3. Copy the sample configuration file and edit it to match your configuration.

    cp .env.example .env

    Twilio API credentials can be found here and find you can create a REST API Key here. If using the twilio CLI you can run:

    twilio api:core:keys:create --friendly-name=worm-transfer -o json

    Copy or create a Twilio phone number from here.

  4. Run the migrations with:

    python manage.py db upgrade
  5. Modify seed data:

    We have provided an example of name and phone number in the seed data. In order for the application to send sms notifications, you must edit this seed data providing a real phone number where you want the sms notifications to be received.

    In order to do this, you must modify this file that is located at: project_root/manage.py

  6. Seed the database:

    python manage.py dbseed
  7. Expose your application to the wider internet using ngrok. You can click here for more details. This step is important because the application won't work as expected if you run it through localhost.

    ngrok http 5000
  8. Start the development server:

    python manage.py runserver

Once Ngrok is running, open up your browser and go to your Ngrok URL. It will look like this: http://9a159ccf.ngrok.io

That's it!

Run the tests

python manage.py test

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.

eta-notifications-flask's People

Contributors

atbaker avatar dependabot-preview[bot] avatar jefflinwood avatar joliveros avatar kathyguerron avatar maylonpedroso avatar mcelicalderon avatar mmena1 avatar shyba avatar smendes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eta-notifications-flask's Issues

Move views.send_sms_notification to top of module

If we had other miscellaneous functions like this one, I would recommend creating a utils.py module. But since we have just one, let's do this instead:

  1. Move it to the top of the module, above all the route definitions
  2. Add an underscore to the front of its name. This is the way Python programmers (informally) denote private functions

Remove models package

Since we just have one model, it's fine to have one models.py file in the eta_notifications_flask directory instead of a models package with an order module.

Removing the models directory and instead putting Order inside one models.py should make the source code hierarchy a little simpler.

Move update status functions to be model methods instead

The update_order_status and update_notification_status functions in views.py both modify a single order. Let's make them methods on the Order model instead.

For example, this:

def update_notification_status(status, order):
    order.notification_status = status
    db.session.commit()

Could probably just be added to the Order model like this:

def update_notification_status(self, status):
    order.notification_status = status
    db.session.commit()

And then referenced in the views as order.update_notification_status([status])

README tweaks

I think the README overall looks good. We should tweak a couple things though:

  1. Let's add a new step between 5 and 6 that's called "Edit seed data." I accidentally ran the dbseed command before I read that the README recommends editing that data before I run the command.
  2. Let's add a new step to the end of the README that recommends using ngrok to expose your app to the web. You might want to link to the most recent Twilio blog post on ngrok as part of your instructions:

https://www.twilio.com/blog/2015/09/6-awesome-reasons-to-use-ngrok-when-testing-webhooks.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.