Code Monkey home page Code Monkey logo

g_api's Introduction

Project g_api

The g_api project is a repository that utilizes Python, FastAPI, SQL (PostgreSQL), PyDantic data search. It implements a CRUD application with JWT authentication for users, including user registration, login, and post creation. The application allows users to create posts search for posts, store them in the database with proper mapping and data types, and retrieve all searched data with unique identifiers. Additionally, it includes SQL table creation and retrieval based on user or post IDs.

Setup Instructions

  1. Navigate to the project directory:

    cd path/to/your/project
  2. Activate your virtual environment (if you're using one):

    .\env\Scripts\activate 
  3. Install the dependencies:

    pip install -r requirements.txt
  4. Install the dependencies:

     uvicorn main:app --reload

Accessing the API

To access the API, run the server and visit the following URLs:

Endpoints

/ (Root Endpoint)

  • Functionality:
    • Displays a welcome message.
    • Redirects to other endpoints and documentation.

/posts (Get All Posts)

  • Purpose: Retrieve all posts from the database.
  • Functionality:
    • Query all posts from the database.
    • Log the activity.

/posts/{id} (Get Post by ID)

  • Purpose: Retrieve a specific post by ID from the database.
  • Functionality:
    • Query the database for the specified post.
    • Log the activity.

/error (Error Endpoint)

  • Purpose: Demonstrate error handling in the API.
  • Functionality:
    • Throw an HTTP 400 error with a custom message.
    • Log the activity.

/user/sign_up (User Sign-up)

  • Purpose: Register a new user.
  • Functionality:
    • Create a new user record in the database.
    • Log the activity.

/user/login (User Login)

  • Purpose: Authenticate a user and return a JWT token.
  • Functionality:
    • Validate user credentials against database records.
    • Generate a JWT token for valid credentials.
    • Log the activity.

g_api's People

Contributors

amartid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.