-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistration_form.py
More file actions
50 lines (40 loc) · 1.75 KB
/
registration_form.py
File metadata and controls
50 lines (40 loc) · 1.75 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
43
44
45
46
47
48
49
50
"""
Generate a user registration form using FormForge API.
Usage: python registration_form.py
"""
import requests
API_URL = "https://formforge-api.vercel.app/api/json-to-form"
form_definition = {
"title": "Create Account",
"theme": "corporate",
"fields": [
{"name": "first_name", "type": "text", "label": "First Name", "required": True},
{"name": "last_name", "type": "text", "label": "Last Name", "required": True},
{"name": "email", "type": "email", "label": "Work Email", "required": True},
{"name": "company", "type": "text", "label": "Company Name"},
{"name": "role", "type": "select", "label": "Role", "options": [
"Developer", "Designer", "Product Manager", "Engineering Manager", "CTO", "Other"
]},
{"name": "team_size", "type": "select", "label": "Team Size", "options": [
"1-5", "6-20", "21-50", "51-200", "200+"
]},
{"name": "use_case", "type": "textarea", "label": "How do you plan to use the API?"},
{"name": "terms", "type": "checkbox", "label": "I agree to the Terms of Service", "required": True},
{"name": "newsletter", "type": "checkbox", "label": "Send me product updates"}
]
}
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 = "registration-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'])}")
if __name__ == "__main__":
generate_form()