This Update Service is a FastAPI-based API that allows users to retrieve and download the latest version of an application. It is designed to manage versioned .exe
files stored in a structured directory and provide endpoints for accessing the latest updates.
- Python 3.8+
- Pip (Python package manager)
- Git (optional)
-
Clone the repository:
git clone https://github.com/your-repository/update-service.git
-
Navigate to the project directory:
cd update-service
-
Install the required dependencies:
pip install -r requirements.txt
-
Run the FastAPI application:
uvicorn app.main:app --reload
The service will be available at
http://localhost:8000
.
update-service/
│
├── app/
│ ├── main.py # Main application entry
│ ├── version/
│ │ └── filehandle.py # File handling logic for managing versioned files
│ └── exe_files/ # Directory containing versioned `.exe` files
│ └── 1.0.0/
│ └── codboon_1.0.0.exe
│
├── tests/
│ └── test_main.py # Test cases for the API endpoints
│
├── requirements.txt # Python dependencies
└── README.md # Documentation
- URL:
/
- Method:
GET
- Description: Returns a welcome message.
- Response:
{ "message": "Bienvenue sur l'API de mise à jour" }
- URL:
/latest-version
- Method:
GET
- Description: Retrieves the latest available version of the application.
- Response:
- Success:
200 OK
{ "latest_version": "1.0.0" }
- Error:
404 Not Found
if no.exe
files are available.{ "detail": "Aucun fichier .exe disponible" }
- Success:
- URL:
/download-latest
- Method:
GET
- Description: Downloads the latest available
.exe
file. - Response:
- Success:
200 OK
with file download. - Error:
404 Not Found
if no.exe
files are available.{ "detail": "Aucun fichier .exe disponible" }
- Success:
You can test the Update Service using pytest
. The test cases are located in the tests/test_main.py
file.
pytest tests/test_main.py -s
Ensure that the exe_files
directory contains at least one versioned .exe
file for successful tests.
- Place the versioned
.exe
files inside theexe_files
directory following this structure:exe_files/ └── 1.0.0/ └── codboon_1.0.0.exe
- Start the FastAPI service using
uvicorn
. - Access the endpoints using
http://localhost:8000/latest-version
orhttp://localhost:8000/download-latest
.
- Create a new directory inside
exe_files
named after the version (e.g.,2.0.0
) and place the.exe
file inside it.
- The endpoints
/latest-version
and/download-latest
will return a404 Not Found
error with the message "Aucun fichier .exe disponible".
- The service selects the
.exe
file from the directory with the highest version number using a tuple-based comparison.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Feel free to submit a pull request or open an issue to improve this project.
For any questions or feedback, please contact us at [[email protected]].