Spaces:
Sleeping
Download README.md from SingerkoneRKM/microtestfrombook: direct link, hf CLI and curl.
- Browser
- Download file 4.02 kB
-
https://huggingface.co/spaces/SingerkoneRKM/microtestfrombook/resolve/main/README.md
- Command line
-
hf download hf://spaces/SingerkoneRKM/microtestfrombook/README.md
-
curl -L -o README.md https://huggingface.co/spaces/SingerkoneRKM/microtestfrombook/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.32.0
title: Singerkone Quiz
emoji: π
colorFrom: yellow
colorTo: blue
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
Singerkone Quiz App
Pick a book, pick page range, get an MCQ quiz from Gemini, earn stars in the Star Bank.
DEPLOYMENT β DO THIS ONCE
Step 1 β Create the Google Sheet
- Go to Google Sheets, create a new sheet named exactly:
MicroTest_star_App - (The app will auto-create a
QuizLogworksheet on first write β you don't need to add columns manually.)
Step 2 β Create a Google Service Account
This is what lets the app write to your Sheet without you logging in.
- Go to https://console.cloud.google.com/
- Create a new project (or use an existing one) β call it
singerkone-quiz - Enable two APIs: Google Sheets API and Google Drive API
- Go to "IAM & Admin" β "Service Accounts" β "Create Service Account"
- Give it any name (e.g.
quiz-bot), skip role assignment, click Done - Click on the new service account β "Keys" tab β "Add Key" β "Create new key" β JSON β Download
- You now have a JSON file. Keep it safe.
- Open the JSON file β find the
client_email(looks likequiz-bot@singerkone-quiz.iam.gserviceaccount.com) - Share your Google Sheet with that email address, give it Editor access
Step 3 β Get a Gemini API key
- Go to https://aistudio.google.com/apikey
- Click "Create API Key" β copy the key
- Free tier: 1500 requests/day β far more than Singerkone will need
Step 4 β Create the HF Space
- Go to https://huggingface.co/new-space
- Name:
singerkone-quiz(or anything) - SDK: Gradio
- Hardware: CPU basic (free)
- Create
Step 5 β Add secrets to the Space
- In the Space, go to Settings β Variables and secrets β New secret
- Add
GEMINI_API_KEY= (paste the Gemini key) - Add
GOOGLE_SERVICE_ACCOUNT_JSON= (paste the entire contents of the JSON file from Step 2)
Step 6 β Upload files
Upload to the Space repo:
app.pyrequirements.txt- A folder called
books/containing:books/class6/amader_prithibi.pdfbooks/class6/<other_books>.pdf- (Add
books/class5/,books/class7/etc. later β same pattern)
Naming convention: lowercase filenames with underscores. The app shows them as Title Case in the UI.
Step 7 β Test
Open the Space URL. Try a quiz with pages 5-7 of Amader Prithibi. If MCQs appear and Sheet updates, you're done.
Adding more books later
Just upload new PDFs to the right folder. No code changes. The dropdown refreshes from the file system.
If you want to add a new class: create books/class7/ (or whatever) and drop PDFs in.
Cost expectations
Gemini 2.5 Flash-Lite: ~$0.0003 per quiz (5 pages Γ 1 quiz). At 100 quizzes/week from Singerkone: under βΉ3/month. You will likely stay inside the free tier (1500 requests/day) indefinitely.
Known limits and gotchas
- HF Space free tier sleeps after 48 hours of inactivity. First kid to use it after a long gap waits ~30 seconds for cold start. After that, fast for everyone.
- Page rendering is on-demand. A 10-page quiz takes ~5β10 seconds end to end (rendering + Gemini call).
- The 1 GB Space limit fits ~70β100 textbooks at typical PDF sizes. You're nowhere near this.
- If a PDF has copy-disabled protection (like WBBSE textbooks), rendering still works β we render the visual page, not extract text.
- If Gemini returns malformed JSON, the quiz fails with a clear error message. Refresh and try again.
- Star formula: 100% β 5 stars, 80% β 4, 60% β 3, 40% β 2, 20% β 1, below 20% β 0. Change
STARS_FORMULAin app.py to adjust.
File layout in the Space
/
βββ app.py
βββ requirements.txt
βββ README.md (this file)
βββ books/
βββ class5/
β βββ *.pdf
βββ class6/
β βββ amader_prithibi.pdf
β βββ *.pdf
βββ class7/
βββ *.pdf