| |
| |
| |
| |
| |
|
|
| export interface PythonTopic { |
| id: string; |
| chapter_no: number; |
| chapter_name: string; |
| subtitle: string; |
| level: string; |
| section?: string; |
| } |
|
|
| export interface PythonSection { |
| title: string; |
| content?: string; |
| code?: string[]; |
| section_number?: string; |
| |
| [key: string]: any; |
| } |
|
|
| export interface PythonTopicContent { |
| id: string; |
| chapter_no: number; |
| chapter_name: string; |
| subtitle?: string; |
| level: string; |
| sections: PythonSection[]; |
| } |
|
|
| export async function fetchPythonTopics(): Promise<PythonTopic[]> { |
| const res = await fetch('/api/python/topics', { |
| method: 'GET', |
| headers: { 'Content-Type': 'application/json' }, |
| }); |
| if (!res.ok) throw new Error(`Python topics fetch failed: ${res.status}`); |
| const data = await res.json(); |
| return data.topics ?? []; |
| } |
|
|
| export async function fetchPythonTopicContent(chapterNo: number): Promise<PythonTopicContent> { |
| const res = await fetch(`/api/python/topics/${chapterNo}`, { |
| method: 'GET', |
| headers: { 'Content-Type': 'application/json' }, |
| }); |
| if (!res.ok) throw new Error(`Python topic content fetch failed: ${res.status}`); |
| return res.json(); |
| } |
|
|