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
# Use Twilio in combination with the libraries `flask` and `pyngrok` to build a tiny server | |
# that uses a webhook to receive text responses when a prompt is initiated. The prompt will | |
# wait until a response text is received (via the webhook). You can find docs and a basic `flask` | |
# example for `pyngrok` here: https://pyngrok.readthedocs.io/en/latest/integrations.html#flask | |
import os | |
import time | |
from threading import Thread | |
from flask import Flask, Response |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 os | |
import sys | |
from urllib.parse import urlparse | |
from django.apps import AppConfig | |
from django.conf import settings | |
class CommonConfig(AppConfig): | |
name = "myproject.common" |
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
# USE_NGROK=True FLASK_APP=server.py flask run | |
import os | |
import sys | |
from flask import Flask | |
def init_webhooks(base_url): | |
# Update inbound traffic via APIs to use the public-facing ngrok URL | |
pass |
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
# USE_NGROK=True uvicorn server:app | |
import os | |
import sys | |
from fastapi import FastAPI | |
from fastapi.logger import logger | |
from pydantic import BaseSettings | |
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 unittest | |
import threading | |
from flask import request | |
from pyngrok import ngrok | |
from urllib import request | |
from server import create_app | |
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 json | |
from flask import Blueprint, request | |
from lambdas.foo_GET import lambda_function as foo_GET | |
bp = Blueprint("lambda_routes", __name__) | |
@bp.route("/foo") | |
def route_foo(): | |
# This becomes the event in the Lambda handler |
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 os | |
from http.server import HTTPServer, BaseHTTPRequestHandler | |
from pyngrok import ngrok | |
port = os.environ.get("PORT", "80") | |
server_address = ("", port) | |
httpd = HTTPServer(server_address, BaseHTTPRequestHandler) |
NewerOlder