-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact_form.py
More file actions
42 lines (32 loc) · 1.23 KB
/
contact_form.py
File metadata and controls
42 lines (32 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Generate a contact form using FormForge API.
Usage: python contact_form.py
"""
import requests
API_URL = "https://formforge-api.vercel.app/api/json-to-form"
form_definition = {
"title": "Contact Us",
"theme": "modern",
"fields": [
{"name": "name", "type": "text", "label": "Full Name", "required": True},
{"name": "email", "type": "email", "label": "Email", "required": True},
{"name": "subject", "type": "select", "label": "Subject", "options": ["General Inquiry", "Support", "Partnership", "Other"]},
{"name": "message", "type": "textarea", "label": "Message", "required": True}
]
}
def generate_form():
response = requests.post(API_URL, json=form_definition)
if response.status_code != 200:
print(f"Error: {response.status_code}")
print(response.text)
return
result = response.json()
filename = "contact-form.html"
with open(filename, "w", encoding="utf-8") as f:
f.write(result["html"])
print(f"Form saved to {filename}")
print(f"Theme: {form_definition['theme']}")
print(f"Fields: {len(form_definition['fields'])}")
print("Open it in your browser to see the styled form.")
if __name__ == "__main__":
generate_form()