personal-blog-api Svelte Themes

Personal Blog Api

(DISCONTINUE) API Blog for Personal - Migrate to Svelte

API for Personal Blog Project

Preview :


Backend Setup :

  • Python 3.11.4
  • FastAPI 0.101.1
  • pymysql 1.1.0
  • Docker as Database Management (phpmyadmin and mysql) for Development
  • Docker for deployment

Be carefull with python version. Always using environment like anaconda/miniconda/virtualenv for setup backend. Don't forget to activate environment.

Want to contribute? Great!

Development

Create python env using miniconda/anaconda

conda create --name personal-blog-api

Activate python env

conda activate personal-blog-api

Note: activate environment and set python interpreter to your environment. if using vscode do ctrl+shift+p then write python interpreter, after that select the right environment After select python interpreter, kill terminal in vscode then add terminal to prevent environment still work in global

Generate Key for Private Key, Public Key, Refresh Private Key

generate private key

openssl genrsa -out private.pem 2048

generate public key

openssl rsa -in private.pem -outform PEM -pubout -out public.pem

generate private key for refresh

openssl genrsa -out private-refresh.pem 2048

Setup database for development

Add database image in docker with phpmyadmin

docker-compose -f docker-compose.dev.yml up --build -d

Alternate way : just install mysql in your local

Connect database

Duplicate alembic.ini.example and renamed it to alembic.ini

Fill this variable in alembic.ini

sqlalchemy.url = mysql+pymysql://{username}:{password}@{host}:{port}/{database}

Duplicate .env.example and renamed it to .env

Fill this variable in .env

DB="mysql+pymysql://{username}:{password}@{host}:{port}/{database}"

Setup project

Install package

pip install -r requirements.txt

Running migration table

alembic upgrade head

Running Application

uvicorn main:app --reload

Look endpoint list in Swagger Documentation

http://localhost:8000/docs

Deploy for production

Up docker

docker-compose up -d --build

Use option --build for first time only or if there a new package

Look endpoint list in local Swagger Documentation (Production)

http://localhost:8120/docs

Should be restart docker if there area updated code in production

Top categories

Loading Svelte Themes