Skip to content

Instantly share code, notes, and snippets.

View alexdlaird's full-sized avatar

Alex Laird alexdlaird

View GitHub Profile
@alexdlaird
alexdlaird / AmazonOrdersIOWithTextPrompt.py
Last active February 7, 2024 21:27
amazon-orders with a Flask / Twilio implementation for 2FA
# 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
@alexdlaird
alexdlaird / hookee-colab-example.ipynb
Last active December 27, 2023 17:41
hookee - Colab Example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexdlaird
alexdlaird / pyngrok-colab-ssh-example.ipynb
Last active December 27, 2023 17:04
pyngrok - Colab SSH Example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexdlaird
alexdlaird / pyngrok-colab-http-example.ipynb
Last active December 27, 2023 17:19
pyngrok - Colab HTTP Example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alexdlaird
alexdlaird / 1_pyngrok_DjangoExample_apps.py
Last active March 5, 2024 18:20
Django integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
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"
@alexdlaird
alexdlaird / pyngrok_FlaskExample_server.py
Last active March 5, 2024 18:20
Flask integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
# 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
@alexdlaird
alexdlaird / pyngrok_FastApiExample_server.py
Last active March 5, 2024 18:22
Fast API integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
# USE_NGROK=True uvicorn server:app
import os
import sys
from fastapi import FastAPI
from fastapi.logger import logger
from pydantic import BaseSettings
@alexdlaird
alexdlaird / pyngrok_EndToEndTestingExample_pyngroktestcase.py
Last active September 18, 2023 19:19
End-to-end testing example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
import unittest
import threading
from flask import request
from pyngrok import ngrok
from urllib import request
from server import create_app
@alexdlaird
alexdlaird / pyngrok_AWSLambdaFlaskExample_server.py
Last active July 14, 2020 18:17
AWS Lambda Flask integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
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
@alexdlaird
alexdlaird / pyngrok_HttpServerExample_server.py
Last active September 18, 2023 19:19
HTTP server integration example for pyngrok, full documentation found at https://pyngrok.readthedocs.io/en/latest/integrations.html
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)