This is a simple Flask application that provides two routes: a home route and a message analysis route.
REMARK: The vast majority of this project (directory structure, contents of files, unit tests, the skeleton of this README.md) was generated using the GitHub Copilot and GitHub Copilot Chat plug-ins of Visual Studio Code.
Create the environment:
> cd ExampleFlaskProject
> python -m venv .venv
> .venv\Scripts\activate.bat
Install the required packages using pip:
(env) pip install -r requirements.txt
To run the application, navigate to the app directory and run the following command:
> cd ExampleFlaskProject
> python .\app\routes.py
The application provides two routes:
- Home route (
/
): Returns a JSON response with a 'message' key set to 'Hello, World!'.> curl -X GET http://localhost:5000
- Message analysis route (
/analyze_message
): Analyzes the message received from the request and returns the word count.> curl -X POST -H "Content-Type: application/json" -d "{\"message\":\"Hello, World!\"}" http://localhost:5000/analyze_message
To run tests, navigate to the tests directory and run the one of the following commands:
> cd ExampleFlaskProject
> python -m unittest discover -v
> python -m unittest -v .\tests\test_routes.py
GET /
Returns a JSON response with a 'message' key set to 'Hello, World!'.
POST /analyze_message
Analyzes the message received from the request and returns the word count.
Parameter | Type | Description |
---|---|---|
message |
string |
Required. Your message |
MIT