added README

This commit is contained in:
2025-12-01 19:07:30 +01:00
parent 4045779947
commit 46c889be59
5 changed files with 92 additions and 34 deletions
Generated
+18 -18
View File
@@ -253,6 +253,24 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]]
name = "form-generator"
version = "0.1.0"
dependencies = [
"anyhow",
"askama",
"axum",
"chrono",
"serde",
"serde_json",
"tokio",
"toml",
"tower-http",
"tower_governor",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "form_urlencoded"
version = "1.2.2"
@@ -697,24 +715,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "polar-pigeons-form"
version = "0.1.0"
dependencies = [
"anyhow",
"askama",
"axum",
"chrono",
"serde",
"serde_json",
"tokio",
"toml",
"tower-http",
"tower_governor",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "portable-atomic"
version = "1.11.1"
+1 -1
View File
@@ -1,5 +1,5 @@
[package]
name = "polar-pigeons-form"
name = "form-generator"
version = "0.1.0"
edition = "2024"
+31
View File
@@ -0,0 +1,31 @@
# Form Generator
A lightweight application for generating dynamic form websites and storing user responses. The form fields, labels, and behavior are fully configurable via a TOML configuration file.
## Usage
The server will listen on `127.0.0.1:8081` by default. You can override with:
```bash
SERVER_PORT=8082 form-generator
```
## Configuration
The application is configured via a TOML file (default: `config.toml`).
See [config.toml](./config.toml) for an example.
### Configuration Fields
* `json_output`: Path to the JSON file where responses are stored.
* `submit_button`: Text displayed on the forms submit button.
* `fields`: List of form fields
* `name`: Internal key for storage.
* `title`: Label displayed in the form.
* `description`: Short description displayed below the field.
* `answer_type`: Type of input (`text`, `number`, `email`, `password`, `url`, `tel`, `textarea`).
* `html_before` (optional): HTML snippet rendered before the field.
* `html_after` (optional): HTML snippet rendered after the field.
+15
View File
@@ -0,0 +1,15 @@
[
{
"timestamp": "2025-12-01T17:58:25.865893826Z",
"answers": {
"about_you": "",
"password": "!Y%5#yH^QcZmwHR",
"age": "",
"favorite_color": "",
"email": "foobar@mail.com",
"website": "",
"full_name": "",
"contact_number": ""
}
}
]
+27 -15
View File
@@ -1,41 +1,53 @@
json_output = "answers.json"
submit_button = "Send"
[[fields]]
name = "full_name"
title = "Full Name"
description = "Your full name"
answer_type = "text"
html_before = "<h2>Identity</h2>"
[[fields]]
name = "age"
title = "Age"
description = "Your age"
answer_type = "number"
[[fields]]
name = "email"
title = "Email Address"
description = "Your email address"
answer_type = "email"
[[fields]]
name = "password"
description = "Set a password"
answer_type = "password"
[[fields]]
name = "website"
description = "Personal website (optional)"
answer_type = "url"
[[fields]]
name = "about_you"
description = "Tell us about yourself"
answer_type = "textarea"
html_before = "<h2>Contact Info</h2>"
[[fields]]
name = "contact_number"
title = "Contact Number"
description = "Phone number"
answer_type = "tel"
[[fields]]
name = "website"
title = "Website"
description = "Personal website (optional)"
answer_type = "url"
html_after = "<h2>More About You</h2>"
[[fields]]
name = "about_you"
title = "About You"
description = "Tell us about yourself"
answer_type = "textarea"
[[fields]]
name = "favorite_color"
title = "Favorite Color"
description = "Favorite color (text)"
answer_type = "text"
[[fields]]
name = "password"
title = "Password"
description = "Set a password"
answer_type = "password"