This commit is contained in:
Flatlogic Bot 2025-11-30 16:52:35 +00:00
parent 281ac84fe1
commit e863dc970a
10 changed files with 237 additions and 183 deletions

Binary file not shown.

Binary file not shown.

View File

@ -14,12 +14,17 @@
<meta property="twitter:image" content="{{ project_image_url }}">
{% endif %}
{% load static %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
{% block head %}{% endblock %}
</head>
<body>
{% block content %}{% endblock %}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</body>
</html>

View File

@ -1,145 +1,51 @@
{% extends "base.html" %}
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ project_name }}{% endblock %}
{% block head %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
}
body::before {
content: '';
position: absolute;
inset: 0;
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'><path d='M-10 10L110 10M10 -10L10 110' stroke-width='1' stroke='rgba(255,255,255,0.05)'/></svg>");
animation: bg-pan 20s linear infinite;
z-index: -1;
}
@keyframes bg-pan {
0% {
background-position: 0% 0%;
}
100% {
background-position: 100% 100%;
}
}
main {
padding: 2rem;
}
.card {
background: var(--card-bg-color);
border: 1px solid var(--card-border-color);
border-radius: 16px;
padding: 2.5rem 2rem;
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
}
h1 {
font-size: clamp(2.2rem, 3vw + 1.2rem, 3.2rem);
font-weight: 700;
margin: 0 0 1.2rem;
letter-spacing: -0.02em;
}
p {
margin: 0.5rem 0;
font-size: 1.1rem;
opacity: 0.92;
}
.loader {
margin: 1.5rem auto;
width: 56px;
height: 56px;
border: 4px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.runtime code {
background: rgba(0, 0, 0, 0.25);
padding: 0.15rem 0.45rem;
border-radius: 4px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
footer {
position: absolute;
bottom: 1rem;
width: 100%;
text-align: center;
font-size: 0.85rem;
opacity: 0.75;
}
</style>
{% endblock %}
{% block title %}ExamAid - AI-Powered Study Assistant{% endblock %}
{% block content %}
<main>
<div class="card">
<h1>Analyzing your requirements and generating your app…</h1>
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<span class="sr-only">Loading…</span>
<div class="bg-gradient-primary hero-section">
<div class="container text-center">
<h1 class="display-4">Welcome to ExamAid</h1>
<p class="lead">Your AI-powered study assistant for competitive exams.</p>
</div>
<p class="hint">AppWizzy AI is collecting your requirements and applying the first changes.</p>
<p class="hint">This page will refresh automatically as the plan is implemented.</p>
<p class="runtime">
Runtime: Django <code>{{ django_version }}</code> · Python <code>{{ python_version }}</code>
— UTC <code>{{ current_time|date:"Y-m-d H:i:s" }}</code>
</p>
</div>
</main>
<footer>
Page updated: {{ current_time|date:"Y-m-d H:i:s" }} (UTC)
</footer>
{% endblock %}
</div>
<div class="container my-5">
<div class="row">
<div class="col-md-6">
<h2>Generate MCQs</h2>
<p>Enter a topic to generate multiple-choice questions with detailed explanations.</p>
<form method="post">
{% csrf_token %}
<div class="mb-3">
<label for="topic" class="form-label">Topic</label>
<input type="text" class="form-control" id="topic" name="topic" required>
</div>
<button type="submit" class="btn btn-primary">Generate MCQs</button>
</form>
</div>
<div class="col-md-6">
<h2>Generated Questions</h2>
{% if mcqs %}
{% for mcq in mcqs %}
<div class="question-card">
<h5>{{ mcq.question }}</h5>
<ul class="options">
{% for option in mcq.options %}
<li>{{ option }}</li>
{% endfor %}
</ul>
<div class="explanation">
<p><strong>Correct Answer:</strong> {{ mcq.correct_answer }}</p>
<p><strong>Explanation:</strong> {{ mcq.explanation }}</p>
</div>
</div>
{% endfor %}
{% else %}
<p>No questions generated yet. Use the form to generate some!</p>
{% endif %}
</div>
</div>
</div>
{% endblock %}

View File

@ -1,7 +1,7 @@
from django.urls import path
from .views import home
from .views import index
urlpatterns = [
path("", home, name="home"),
path("", index, name="index"),
]

View File

@ -1,25 +1,39 @@
import os
import platform
from django import get_version as django_version
import json
from django.shortcuts import render
from django.utils import timezone
from ai.local_ai_api import LocalAIApi
def index(request):
"""Render the landing page and handle MCQ generation."""
context = {}
if request.method == "POST":
topic = request.POST.get("topic")
if topic:
# This is a simplified example. In a real app, you would have
# more sophisticated error handling and prompt engineering.
response = LocalAIApi.create_response(
{
"input": [
{'role': 'system', 'content': 'You are an educational content generator. Produce a JSON array of 3 objects, where each object has the following structure: {"question": "...", "options": ["...", "...", "...", "..."], "correct_answer": "...", "explanation": "..."}. The topic is ' + topic + '. Return ONLY valid JSON.'}, {"role": "user", "content": "Generate 3 MCQs about " + topic},
],
}
)
def home(request):
"""Render the landing screen with loader and environment details."""
host_name = request.get_host().lower()
agent_brand = "AppWizzy" if host_name == "appwizzy.com" else "Flatlogic"
now = timezone.now()
if response.get("success"):
# The AI response might be a string that needs to be parsed as JSON.
# It's important to handle potential JSON parsing errors.
try:
raw_text = LocalAIApi.extract_text(response)
mcqs = json.loads(raw_text)
# Basic validation to ensure we have a list
if isinstance(mcqs, list):
context["mcqs"] = mcqs
else:
context["error"] = "AI returned data in an unexpected format."
except json.JSONDecodeError:
context["error"] = "Failed to parse the response from the AI."
except Exception as e:
context["error"] = f"An unexpected error occurred: {e}"
else:
context["error"] = response.get("error", "An unknown error occurred with the AI service.")
context = {
"project_name": "New Style",
"agent_brand": agent_brand,
"django_version": django_version(),
"python_version": platform.python_version(),
"current_time": now,
"host_name": host_name,
"project_description": os.getenv("PROJECT_DESCRIPTION", ""),
"project_image_url": os.getenv("PROJECT_IMAGE_URL", ""),
}
return render(request, "core/index.html", context)

View File

@ -1,4 +1,77 @@
/* Custom styles for the application */
body {
font-family: system-ui, -apple-system, sans-serif;
:root {
--bs-primary: #4F46E5;
--bs-secondary: #10B981;
--bs-accent: #F59E0B;
--bs-neutral-light: #F9FAFB;
--bs-neutral-dark: #111827;
--bs-font-sans-serif: "Inter", sans-serif;
--bs-font-monospace: "Poppins", sans-serif;
}
body {
font-family: var(--bs-font-sans-serif);
background-color: var(--bs-neutral-light);
color: var(--bs-neutral-dark);
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--bs-font-monospace);
font-weight: 600;
}
.btn-primary {
background-color: var(--bs-primary);
border-color: var(--bs-primary);
}
.btn-primary:hover {
background-color: #4338ca;
border-color: #4338ca;
}
.btn-secondary {
background-color: var(--bs-secondary);
border-color: var(--bs-secondary);
}
.btn-secondary:hover {
background-color: #059669;
border-color: #059669;
}
.bg-gradient-primary {
background: linear-gradient(90deg, var(--bs-primary), var(--bs-secondary));
}
.hero-section {
padding: 6rem 0;
color: white;
}
.question-card {
border: 1px solid #e5e7eb;
border-radius: 0.5rem;
padding: 1.5rem;
margin-bottom: 1.5rem;
background-color: white;
}
.question-card h5 {
font-weight: 600;
}
.question-card .options {
list-style-type: none;
padding-left: 0;
}
.question-card .options li {
padding: 0.5rem 0;
}
.question-card .explanation {
margin-top: 1rem;
padding-top: 1rem;
border-top: 1px solid #e5e7eb;
font-size: 0.9rem;
}

View File

@ -1,21 +1,77 @@
:root {
--bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
--text-color: #ffffff;
--card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
--bs-primary: #4F46E5;
--bs-secondary: #10B981;
--bs-accent: #F59E0B;
--bs-neutral-light: #F9FAFB;
--bs-neutral-dark: #111827;
--bs-font-sans-serif: "Inter", sans-serif;
--bs-font-monospace: "Poppins", sans-serif;
}
body {
margin: 0;
font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
text-align: center;
overflow: hidden;
position: relative;
font-family: var(--bs-font-sans-serif);
background-color: var(--bs-neutral-light);
color: var(--bs-neutral-dark);
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--bs-font-monospace);
font-weight: 600;
}
.btn-primary {
background-color: var(--bs-primary);
border-color: var(--bs-primary);
}
.btn-primary:hover {
background-color: #4338ca;
border-color: #4338ca;
}
.btn-secondary {
background-color: var(--bs-secondary);
border-color: var(--bs-secondary);
}
.btn-secondary:hover {
background-color: #059669;
border-color: #059669;
}
.bg-gradient-primary {
background: linear-gradient(90deg, var(--bs-primary), var(--bs-secondary));
}
.hero-section {
padding: 6rem 0;
color: white;
}
.question-card {
border: 1px solid #e5e7eb;
border-radius: 0.5rem;
padding: 1.5rem;
margin-bottom: 1.5rem;
background-color: white;
}
.question-card h5 {
font-weight: 600;
}
.question-card .options {
list-style-type: none;
padding-left: 0;
}
.question-card .options li {
padding: 0.5rem 0;
}
.question-card .explanation {
margin-top: 1rem;
padding-top: 1rem;
border-top: 1px solid #e5e7eb;
font-size: 0.9rem;
}