File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
12# forms
2- Website forms handler
3+
4+ A simple HTTP service for handling website form submissions and forwarding them to a Telegram chat.
5+
6+ ## Features
7+ - Accepts POST requests with JSON, form, or multipart data
8+ - Forwards form data and file uploads to a specified Telegram chat
9+ - Supports plain text, JSON, and file payloads
10+ - Deployable via Docker and Nomad
11+
12+ ## Requirements
13+ - Python 3.12+
14+ - [ Flask] ( https://flask.palletsprojects.com/ )
15+ - [ Requests] ( https://docs.python-requests.org/ )
16+
17+ ## Environment Variables
18+ - ` TELEGRAM_BOT_TOKEN ` (required): Telegram bot token for sending messages
19+
20+ ## Usage
21+
22+ ### Local Development
23+ 1 . Install dependencies:
24+ ```bash
25+ pip install -r requirements.txt
26+ ```
27+ 2 . Set the Telegram bot token:
28+ ```bash
29+ export TELEGRAM_BOT_TOKEN=your-telegram-bot-token
30+ ```
31+ 3 . Run the app:
32+ ```bash
33+ python app.py
34+ ```
35+ The service will listen on `0.0.0.0:8010`.
36+
37+ ### Endpoints
38+ - ` GET / ` — Health check, returns ` ok ` .
39+ - ` POST /post ` — Accepts form submissions. Forwards data and files to Telegram.
40+
41+ #### Example cURL
42+ ``` bash
43+ curl -X POST http://localhost:8010/post \
44+ -F " name=John Doe" \
45+ -F " email=john@example.com" \
46+ -F " file=@/path/to/file.pdf"
47+ ```
48+
49+ ## Docker
50+ Build and run the service with Docker:
51+ ``` bash
52+ docker build -t forms .
53+ docker run -e TELEGRAM_BOT_TOKEN=your-telegram-bot-token -p 8010:8010 forms
54+ ```
55+
56+ ## Nomad Deployment
57+ See ` nomad-job.hcl ` for a sample Nomad job spec. The service expects the ` TELEGRAM_BOT_TOKEN ` to be provided as an environment variable.
58+
59+ ## License
60+ MIT
You can’t perform that action at this time.
0 commit comments