Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

📨 Example Flask SMS Gateway Webhook Processor | HMAC Security + Pydantic Validation | Auto-Registration

License

NotificationsYou must be signed in to change notification settings

android-sms-gateway/example-webhooks-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExampleLicensePythonFlask

⚠️ Example Project Notice
Not intended for production use without proper security review and modifications.

📋 Table of Contents

✨ About The Project

Example Project Features:

  • 🧩 Demonstrates webhook registration/deregistration lifecycle
  • 🔐 Example HMAC signature validation implementation
  • 📝 Sample payload validation using Pydantic models
  • 🔄 Synchronous Flask implementation

🛠️ Built With

  • 🚀Flask - Lightweight Python web framework
  • ✔️Pydantic - Data validation and settings management
  • 🌐HTTPX - Synchronous HTTP client

⚠️ Important Notes

This example intentionally omits:

  • Production-grade error handling
  • Rate limiting
  • Persistent storage integration
  • Advanced security features

Recommended for:

  • 🧪 Testing SMS Gate webhook integration
  • 🎓 Learning Flask webhook implementations

🚀 Getting Started

📦 Prerequisites

  • Python 3.9+ (development environment)
  • Valid SSL certificate (project's CA available) or reverse proxy (likengrok)
  • SMS Gate credentials

⚡ Installation

  1. Clone the example repository:

    git clone https://github.com/android-sms-gateway/example-webhooks-flask.gitcd example-webhooks-flask
  2. Install dependencies:

    pip install -r requirements.txt
  3. Create environment file:

    cp .env.example .env

⚙️ Configuration

Example.env configuration:

# 🔑 Example SMS Gate API CredentialsFLASK_SMS_GATE_API_URL="https://api.sms-gate.app/3rdparty/v1"# API root endpoint (optional)FLASK_SMS_GATE_API_USERNAME="test_user"# API usernameFLASK_SMS_GATE_API_PASSWORD="test_password"# API password# 🔒 Example Webhook SecurityFLASK_WEBHOOK_SECRET="your_test_secret_here"# signing key (optional)FLASK_WEBHOOK_URL="https://localhost:8443/webhook/sms-received"# current server endpoint# 🛡️ SSL ConfigurationFLASK_SSL_CERT_PATH="./certs/server.crt"# SSL certificate (optional)FLASK_SSL_KEY_PATH="./certs/server.key"# SSL private key (optional)

🖥️ Usage

Run the server:

python app.py

Expected output:

Registered webhook ID: 6GlbDer5u83MLiupOKXxf * Serving Flask app 'main' * Debug mode: offWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on all addresses (0.0.0.0) * Running on http://127.0.0.1:8080 * Running on http://10.10.0.2:8080Press CTRL+C to quitReceived SMS:SIM: 1From: 6505551212Message: Android is always a sweet treat!Received at: 2025-04-15 15:50:56+07:00127.0.0.1 - - [15/Apr/2025 15:50:59] "POST /webhook/sms-received HTTP/1.1" 200 -^CUnregistered webhook ID: 6GlbDer5u83MLiupOKXxf

📚 API Reference

POST /webhook/sms-received

Example Request:

curl -X POST https://localhost:8443/webhook/sms-received \  -H"X-Signature: abc123..." \  -H"X-Timestamp: 1690123456" \  -d @sample_payload.json

Example Response:

{"status":"ok"}

🤝 Contributing

This example project welcomes contributions to:

  • Improve documentation
  • Demonstrate additional features
  • Enhance example security implementations

📜 License

This example code is released underApache License 2.0.

About

📨 Example Flask SMS Gateway Webhook Processor | HMAC Security + Pydantic Validation | Auto-Registration

Topics

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp