DogeAPI

  • FastApi is built on a Python framework called Starlette which is a lightweight ASGI framework/toolkit, which is itself built on Uvicorn.
  • Ideal for building high performance asyncio services with seriously impressive performance.
  • That why DogeAPI is here, an API with high performance built with FastAPI & SQLAlchemy, help to improve connection with your Backend Side and stay relate using SQLite3 & a secure Schema Based on Python-Jose a JavaScript Object Signing and Encryption implementation in Python.

Installation

  • With a simple steps you can install DogeAPI.

  • clone the repository:

    git clone https://github.com/yezz123/DogeAPI.git

  • Create & activate a python3 virtual environment (optional, but very recommended).

  • Install requirements:

    pip install -r requirements.txt

  • Run the app locally :

    uvicorn main:app --reload

  • Port already in use? Close the other app, or use a difference port:

    uvicorn main:app --port 8001 --reload

Into Code

  • If you want to Set environment variables you need to check token.py and use :

    openssl rand -hex 32

  • To get a string like this.

    SECRET_KEY = "a4ee1c733a80a5ac8824ac21b90ee6ae0158aee6642880fb2675929f99b1a677"
    ALGORITHM = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES = 30

  • I Use a simple Model to implement with Database & the default configuration.

  • This for the Blog Table

    class Blog(Base):
    tablename = "blogs"
    id = Column(Integer, primary_key=True,index=True)
    title = Column(String)
    body = Column(String)
    user_id = Column(Integer, ForeignKey("users.id"))
    creator = relationship("User", back_populates="blogs")

  • This for The Users Table

    class User(Base):
    tablename = "users"
    id = Column(Integer, primary_key=True,index=True)
    name = Column(String)
    email = Column(String)
    password = Column(String)
    blogs = relationship("Blog", back_populates="creator")

  • For database i use SQLAlchemy.ORM to create a sessions.

    SessionLocal = sessionmaker(bind=engine, autocommit=False, autoflush=False)
    Base = declarative_base()

GitHub

https://github.com/yezz123/DogeAPI