Notes
Notes - notes.io |
1. HTML, CSS, and JavaScript for the UI.
2. reCAPTCHA for security before submission.
3. FastAPI backend to handle form submission.
---
Frontend: index.html
This includes:
A logo and company name in the header.
A form with email, dropdowns, and text area.
A captcha validation before submission.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Company Form</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/css/select2.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/js/select2.min.js"></script>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<style>
body { font-family: 'Ubuntu', sans-serif; }
header { background: #f8f9fa; padding: 15px; text-align: center; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); }
header img { width: 80px; margin-right: 15px; }
main { max-width: 600px; margin: 30px auto; padding: 20px; border: 1px solid #ddd; border-radius: 5px; }
h2 { color: #09455C; }
.select2-container { min-width: 100%; }
</style>
</head>
<body>
<header>
<img src="logo.png" alt="Company Logo">
<h2>Company Name</h2>
</header>
<main>
<form id="form">
<div class="mb-3">
<label for="email" class="form-label">Email:</label>
<input type="email" id="email" class="form-control" required>
</div>
<div class="mb-3">
<label for="studyType" class="form-label">Type:</label>
<select id="studyType" class="form-select">
<option value="slide">PowerPoint Slide</option>
<option value="quiz">Quiz/Test</option>
<option value="guide">Study Guide</option>
</select>
</div>
<div class="mb-3">
<label for="notes" class="form-label">Custom Notes:</label>
<textarea id="notes" class="form-control" rows="4"></textarea>
</div>
<div class="mb-3">
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
</div>
<button type="submit" class="btn btn-primary" id="submitBtn">Submit</button>
</form>
</main>
<script>
$(document).ready(function() {
$("#studyType").select2();
});
$("#form").on("submit", function(event) {
event.preventDefault();
let email = $("#email").val();
let studyType = $("#studyType").val();
let notes = $("#notes").val();
let recaptchaResponse = grecaptcha.getResponse();
if (!recaptchaResponse) {
alert("Please complete the CAPTCHA!");
return;
}
fetch("http://127.0.0.1:8000/submit", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, studyType, notes, recaptchaResponse })
})
.then(response => response.json())
.then(data => alert(data.message))
.catch(error => console.error("Error:", error));
});
</script>
</body>
</html>
---
Backend: FastAPI (main.py)
This script:
Handles form submission with a POST request.
Validates reCAPTCHA with Google's API.
Returns a JSON response.
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
import httpx
app = FastAPI()
# Replace with your actual Google reCAPTCHA secret key
RECAPTCHA_SECRET = "your_secret_key"
class FormData(BaseModel):
email: str
studyType: str
notes: str
recaptchaResponse: str
@app.post("/submit")
async def submit_form(data: FormData):
# Verify reCAPTCHA
async with httpx.AsyncClient() as client:
response = await client.post(
"https://www.google.com/recaptcha/api/siteverify",
data={"secret": RECAPTCHA_SECRET, "response": data.recaptchaResponse},
)
result = response.json()
if not result.get("success"):
raise HTTPException(status_code=400, detail="Invalid reCAPTCHA")
return {"message": "Form submitted successfully"}
---
Running the FastAPI Server
1. Install dependencies:
pip install fastapi uvicorn httpx pydantic
2. Run the FastAPI server:
uvicorn main:app --reload
3. The API will be available at: http://127.0.0.1:8000/submit
---
Summary
The frontend (HTML, CSS, JS) provides a user-friendly form.
reCAPTCHA prevents bots from submitting.
The FastAPI backend validates the reCAPTCHA and processes the form.
Let me know if you need modifications!
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
