ng generate component component-name
, but for your own projectsng generate component component-name
python --version
python -m venv env
scripts/env
print("this will create a new page in the app")
print("this will parse the data")
"cp": "cd scripts && python create-page.py","pd": "cd scripts && python parse-data.py",
npm run cp
npm run pd
npm i
npm run dev
import rawFlashcards from "../../parseddata/flashcards.json";
itand it will take some timee ci vorrà del tempoitthis will ensure that you getcìo garantirà di ottenereesthis has certain advantagesest tiene ciertas ventajasesin such a way thatde tal manera que
def devlog(line: str):print(f"DEBUG ### {line} ################################")
import osdef get_lines_from_file(file_name: str) -> list[str]:"""Get all lines from a file as a list of strings.Usage:lines = get_lines_from_file("../../notes.txt")"""try:with open(file_name, "r", encoding="utf-8") as f:contents = f.read()except Exception as e:raise RuntimeError(f"Failed to read file: {e}")lines = [line.strip() for line in contents.split('\n')]return lines
import utils.debug as debugdebug.devlog("this will create a new page in the app")
"""
comment block inside the function will show up in these editors as well, which gives you context-related help on the functions you are usingimport utils.debug as debugimport utils.files as filesdebug.devlog("this shows the lines of the text file")lines = files.get_lines_from_file("../data/flashcards.txt")for i, line in enumerate(lines, 1):print(f"{i:03d}: {line}")
npm run pd
__pycache__/
import randomimport stringdef generate_short_uuid() -> str:"""Return a random short UUID (6 characters)Example output: "q35HZa""""charset = string.ascii_letters + string.digits # A-Z, a-z, 0-9length = 6return ''.join(random.choice(charset) for _ in range(length))
import utils.debug as debugimport utils.files as filesimport utils.general as generalimport jsonclass Flashcard:def __init__(self, suuid, category, front, back):self.suuid = suuidself.category = categoryself.front = frontself.back = backlines = files.get_lines_from_file("../data/flashcards.txt")flashcards = []for i in range(0, len(lines), 4):if i + 3 > len(lines):breakcategory = lines[i].strip()front = lines[i+1].strip()back = lines[i+2].strip()flashcard = Flashcard(suuid=general.generate_short_uuid(),category=category,front=front,back=back)flashcards.append(flashcard.__dict__)try:# Convert flashcards to JSONjson_data = json.dumps(flashcards, indent=4)# Write JSON data to filewith open("../parseddata/flashcards.json", 'w') as json_file:json_file.write(json_data)print("Successfully updated flashcards.json")except Exception as err:print(f"Error: {err}")
npm run pd
command, a new flashcard will appear on your site