This project is a simple RESTful API for storing and managing code snippets, built with FastAPI and SQLAlchemy.
It lets you create, read, update, and delete code snippets with a topic, optional description, and code body, all stored in a SQLite database.
- Create new code snippets with topic, description, and code
- List all stored snippets
- Retrieve a single snippet by ID
- Delete a snippet
- SQLite database for local or PostgreSQL with Render via SQLAlchemy ORM
- CORS enabled for easy frontend integration
- main.py : Backend handle http method and database
- index.html : Frontend to submit a data or retrieve data from api
- addendum.html : Frontend to create index of code that store in database
-
Clone the repository and open the project folder.
-
(Optional but recommended) Create and activate a virtual environment:
macOS / Linux:
python -m venv venv source venv/bin/activate -
Install dependencies from requirements.txt
pip install -r requirements.txt
-
Run Application Backend
uvicorn main:app --reload or ```bash pip install "fastapi[standard] fastapi dev
-
Run frontend on local host
python3 -m http.server 8000
-
Access index.html by using localhost:8000/index.html