Skip to content

arthurauffray/PyScramble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyScramble API + Module

PyScrambleAPI is a Flask API that unscrambles sets of characters into actual words. It leverages its very own PyScramble module, which ranks potential matches based on their likelihood of being correct.


Contents

  1. Features
  2. Requirements
  3. Installation
  4. Usage
  5. API endpoints
  6. License

Features

  • Simple endpoints: Quickly unscramble letters by sending a POST or GET request with the letters you have.
  • Ranked results: Returns a sorted list of possible words, ranked in order of likelihood by the PyScramble module.
  • Modular: Built with Flask, making it easy to extend or integrate into larger systems.

Requirements

Make sure you have the following installed:

  • Python 3.9.6+

  • pip (or another Python package manager)

  • Flask

  • Flask-Limiter

  • python-dotenv

  • gunicorn (for prod)

  • (Optional) A virtual environment tool (e.g. venv)


Installation

  1. Clone the repository:
    git clone https://github.com/arthurauffray/PyScramble.git
  2. Navigate to the project directory:
    cd PyScramble
  3. Install the dependencies:
    pip install -r requirements.txt
    If desired, create and activate a virtual environment first.
  4. Set the worldist file path: Open the .env file in your editor of choice and set the path of the words.json file (sample provided in /pyscramble/data/)

Usage

  1. Start the Flask server:

    python app.py

    By default, the server runs on http://127.0.0.1:8080.

  2. Send requests to the API endpoints (see below). You can use tools like curl or Postman to test.


API endpoints

Below is a list of the API's endpoints.

POST /unscramble

Description: Accepts a JSON payload containing scrambled letters. Returns a list of possible words ordered by their rank.

Request body:

{
  "letters": "hist"
}

Example:

curl -X POST -H "Content-Type: application/json" \
     -d '{"letters":"hist"}' \
     http://127.0.0.1:8080/unscramble

Response:

{
  "status": "ok", 
  "message": [
    "hist", 
    "hits", 
    "isth", 
    "shit", 
    "sith", 
    "this", 
    "tshi"
  ]
}

GET /unscramble

Description: Accepts a query parameter containing scrambled letters. Returns a list of possible words ordered by their rank.

Request URL:

http://127.0.0.1:8080/unscramble?letters=hist

Example:

curl -G \
     -d "letters=hist" \
     http://127.0.0.1:8080/unscramble

Response:

{
  "status": "ok", 
  "message": [
    "hist", 
    "hits", 
    "isth", 
    "shit", 
    "sith", 
    "this", 
    "tshi"
  ]
}

GET /ping

Description: Returns a status message to check for uptime.

Response:

{
   "status": "ok",
   "message": "Pong!",
}

GET /

Description: Returns a simple status to have a home page.

Response:

{
   "status": "ok"
}

License

This project is available under the MIT License. Feel free to fork, extend, and submit pull requests.


If you have any questions or run into issues, please open an issue in this repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages