This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code for Twilio Functions (https://www.twilio.com/functions) that builds an automated speech recognition IT support desk. | |
// Read the companion blog post (https://www.twilio.com/blog/2017/07/building-the-it-crowd-answering-machine-using-twilio-functions.html) for full explanations. | |
/**************** Version 1 ******************/ | |
exports.handler = function(context, event, callback) { | |
let twiml = new Twilio.twiml.VoiceResponse(); | |
twiml.say({ voice: 'man', language: 'en-gb' }, 'Welcome to the IT support hotline. Sorry, we are currently closed. We don not have any open hours.'); | |
callback(null, twiml); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import json | |
import os | |
import urllib | |
from urllib import request, parse | |
TWILIO_SMS_URL = "https://api.twilio.com/2010-04-01/Accounts/{}/Messages.json" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bottle | |
from bottle import route, run, Response | |
app = bottle.default_app() | |
@route('/') | |
def index(): | |
"""Returns standard text response to show app is working.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" enable syntax highlighting | |
syntax enable | |
" show line numbers | |
set number | |
" set tabs to have 4 spaces | |
set ts=4 | |
" indent when moving to the next line while writing code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bottle import (post, request, response, route, run, ) | |
from twilio import twiml | |
@route('/') | |
def check_app(): | |
# returns a simple string stating the app is working | |
return "It works!" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, Response, request | |
from twilio import twiml | |
app = Flask(__name__) | |
@app.route("/") | |
def check_app(): | |
# returns a simple string stating the app is working |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax on | |
set ts=4 | |
set autoindent | |
set expandtab | |
set shiftwidth=4 | |
let python_highlight_all = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Response> | |
<Message>Thanks for your text message!</Message> | |
</Response> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import environ | |
from fabric.api import * | |
from fabric.context_managers import cd | |
from fabric.contrib.files import sed | |
""" | |
Fabric file to upload public/private keys to remote servers | |
and set up non-root users. Also prevents SSH-ing in with the | |
root user. Fill in the following blank fields then run this | |
Fabric script with "fab bootstrap_ansible". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestSignUp(TestCase): | |
fixtures = ['core-fixtures.json',] | |
def testShowSignUp(self): | |
response = self.client.get('/sign-up/') | |
self.assertContains(response, 'Sign Up', status_code=200) | |
def testSignUpSubmit(self): | |
self.assertEqual(0, len(User.objects.all())) | |
response = self.client.post('/sign-up/', {'first_name': 'John', \ |
NewerOlder