8000 GitHub - JaiswarRohit/Phometa · GitHub
[go: up one dir, main page]

Skip to content
JaiswarRohitPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phometa

Phometa is a secure phone book application built with Flask, SQLAlchemy, and PostgreSQL. It includes features such as user registration, login, contact management, spam number marking, and user search. The application uses JWT for user authentication and Flask-Migrate for database migrations.

Prerequisites

  • Python version >= 3.10
  • PostgreSQL database

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/phometa.git
    cd phometa
  2. Create a virtual environment and activate it:

    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  3. Install the required packages:

    pip install -r requirements.txt

Configuration

  1. Set up the PostgreSQL database: Create a new database in PostgreSQL.

    CREATE DATABASE phometa;
  2. Update the SQLALCHEMY_DATABASE_URI variable in app.py: Open app.py and update the SQLALCHEMY_DATABASE_URI with your local database URL.

    phometa.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://username:password@localhost:5432/Phometa'

Database Migration

  1. Initialize the migration folder:

    flask db init
  2. Generate the migration scripts:

    flask db migrate -m "Initial migration."
  3. Apply the migrations to the database:

    flask db upgrade

Running the Application

  1. Start the Flask application:

    python app.py
  2. The application will be accessible at http://127.0.0.1:5000/.

API Endpoints

User Registration

  • URL: /register

  • Method: POST

  • Payload:

    {
      "name": "John Doe",
      "phone": "1234567890",
      "email": "john.doe@example.com",
      "password": "password123"
    }
  • Response:

    {
      "message": "User created successfully."
    }

User Login

  • URL: /login

  • Method: POST

  • Payload:

    {
      "phone": "1234567890",
      "password": "password123"
    }
  • Response:

    {
      "access_token": "your_access_token"
    }

Add Contact

  • URL: /add-contact

  • Method: POST

  • Headers:

    {
      "Authorization": "Bearer your_access_token"
    }
  • Payload:

    {
      "name": "Jane Doe",
      "phone": "0987654321"
    }
  • Response:

    {
      "message": "Contact added successfully."
    }

Mark Spam

  • URL: /mark-spam

  • Method: POST

  • Headers:

    {
      "Authorization": "Bearer your_access_token"
    }
  • Payload:

    {
      "phone": "0987654321"
    }
  • Response:

    {
      "message": "Number marked as spam."
    }

Search User

  • URL: /search

  • Method: POST

  • Headers:

    {
      "Authorization": "Bearer your_access_token"
    }
  • Payload:

    {
      "name": "Jane Doe",
      "phone": "0987654321"
    }
  • Response:

    {
      "message": "User(s) Found",
      "data": [
        {
          "name": "Jane Doe",
          "phone": "0987654321",
          "spam_reports": 0,
          "contact_name": "Jane",
          "email": "jane.doe@example.com"
        }
      ]
    }

Logout

  • URL: /logout

  • Method: POST

  • Headers:

    {
      "Authorization": "Bearer your_access_token"
    }
  • Response:

    {
      "message": "User logged out successfully. Token Expired."
    }

Data Generation Script

The data.py script can be used to generate random data and test the API endpoints.

  1. Update the API endpoint in data.py:

    api_endpoint = "http://127.0.0.1:5000/"
  2. Run the script:

    python data.py

This script will register random users, log them in, add contacts, mark numbers as spam, and log out.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0