Skip to content
المشاريع

حول

Generic quiz app template - Flask + SQLite + Docker + Cloudflare SSL

الأنظمة والبنية التحتية

كيف تُقاس هذه الأرقام

ما يمكنك فعله

  • Topic filtering - Filter questions by category
  • Quiz modes - Regular quiz, bookmarks only, wrong answers review
  • Dark mode - Toggle with localStorage persistence
  • Explanation popups - Show correct answer and explanation on wrong answers

النمو المقاس للنجوم

خلال 24 ساعة
٠
خلال 7 أيام
جارٍ جمع السجل
خلال 15 يومًا
جارٍ جمع السجل
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

Generic Quiz App

A fully containerized, production-ready quiz application with Flask + SQLite + Docker, designed for any topic or domain.

Features

  • Topic filtering - Filter questions by category
  • Quiz modes - Regular quiz, bookmarks only, wrong answers review
  • Dark mode - Toggle with localStorage persistence
  • Explanation popups - Show correct answer and explanation on wrong answers
  • Progress tracking - Per-browser progress with localStorage (no login required)
  • Responsive design - Works on desktop and mobile
  • Production ready - Gunicorn WSGI server, nginx reverse proxy, SSL/TLS

Tech Stack

  • Backend: Flask (Python), Gunicorn
  • Database: SQLite (file-based, persistent volume)
  • Frontend: Vanilla HTML5, CSS3, JavaScript (no frameworks)
  • Container: Docker + Docker Compose
  • Reverse Proxy: nginx (Alpine)
  • SSL: Cloudflare Origin Certificate (15-year validity)
  • CDN/DDoS: Cloudflare (proxied)

Quick Start

1. Run the setup script

chmod +x setup.sh
./setup.sh

This will prompt you for:

  • Site title (e.g., "AZ-104 Quiz", "AWS Practitioner Prep")
  • Domain name (e.g., "quiz.example.com")

2. Add your questions

Edit questions.json with your quiz questions:

[
  {
    "id": 1,
    "topic": "Category Name",
    "question": "What is the question?",
    "options": {
      "A": "Option A",
      "B": "Option B",
      "C": "Option C",
      "D": "Option D"
    },
    "answer": "B",
    "explanation": "The correct answer is B because..."
  }
]

3. Create Cloudflare Origin Certificate

  1. Log into Cloudflare dashboard
  2. Go to SSL/TLS → Origin Server
  3. Click Create Certificate
  4. Keep defaults (RSA 2048, 15 years)
  5. Download both files:
    • Origin Certificate → save as nginx/certs/cert.pem
    • Private Key → save as nginx/certs/cert.key

4. Add DNS record in Cloudflare

  1. Go to your domain in Cloudflare
  2. DNS → Records → Add record
  3. Type: A
  4. Name: your subdomain (e.g., quiz)
  5. IPv4: your server's public IP
  6. Proxy: ON (orange cloud)

5. Set SSL/TLS mode

In Cloudflare dashboard:

  • Go to SSL/TLS
  • Set encryption mode to Full

6. Deploy

docker compose up -d --build

Your site will be live at https://your-domain.com within a minute.

Directory Structure

.
├── Dockerfile
├── docker-compose.yml
├── setup.sh
├── config.json              (site configuration)
├── questions.json           (your quiz questions)
├── requirements.txt
├── .dockerignore
├── data/                    (auto-created, persistent)
│   └── questions.db
├── nginx/
│   ├── site.conf
│   └── certs/
│       ├── cert.pem         (Cloudflare Origin Certificate)
│       └── cert.key         (Cloudflare Private Key)
├── static/
│   ├── css/
│   │   └── style.css
│   └── js/
│       └── app.js
└── templates/
    └── index.html

Configuration

Site Title

Edit config.json:

{
  "site_title": "Your Quiz Title",
  "site_description": "Description here"
}

Then restart the container:

docker compose restart flask

Adding More Questions

  1. Edit questions.json with your new questions
  2. Restart the Flask container:
docker compose restart flask

The database will be rebuilt automatically with your new questions.

Customizing Styles

Edit static/css/style.css to change colors, fonts, or layout. The app uses CSS variables for theming:

:root {
    --bg-primary: #f5f7fa;
    --accent: #4299e1;
    --success: #48bb78;
    /* ... more variables ... */
}

Then rebuild the container:

docker compose up -d --build

Troubleshooting

Container won't start

Check logs:

docker compose logs nginx
docker compose logs flask

SSL certificate errors

Make sure your certificate files are in the right location:

ls -la nginx/certs/
# Should show cert.pem and cert.key

Questions not loading

Check if the database was created:

docker compose exec flask ls -la /app/data/
# Should show questions.db

DNS not resolving

Wait 5-10 minutes for DNS propagation, or check:

dig your-domain.com

License

MIT License - feel free to use this for any quiz topic or commercial project.

Credits

Built with Flask, Docker, and nginx. Designed for Cloudflare SSL termination.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…