This is my Portfolio's back-end repository, using the python based flask framework.
You can check my Portfolio here.
The project follows the REST API
architectural style, providing endpoints for various operations.
GET /messages
: Retrieves a list of messages for guests.POST /messages
: Adds a new message.GET /admin/messages
: Retrieves a list of messages for administration.PUT /admin/messages/{messageId}/status
: Updates the status of a message.DELETE /admin/messages/{messageId}
: Deletes a message.- j
POST /admin/messages/delete
: Deletes multiple messages based on the provided list of IDs.
This project used the enterprise WeChat application to send notifications to WeChat in real time. When a guest sends a new message, a enterprise WeChat notification will be sent. In the environment variables below, CORPID
, AGENTID
, CORPSECRET
and ADMINURL
are environment variables related to enterprise WeChat notifications. If you don’t need them, just comment them out.
- You can check here to get more information about Enterprise WeChat sends application messages
This project used pytest
as the api testing framework, and created a test_api.py
file in the root directory.
All interfaces can be tested with the following command:
pytest test_api.py
-
Clone the repository:
git clone https://github.com/Chenmo1212/homepage_backend.git
-
Navigate to the project directory:
cd your-repository
-
Create virtual environment:
python -m venv venv
-
Install the dependencies after entering the virtual environment just created:
pip install -r requirements.txt
-
Set up the environment variables:
-
Create a
.env
file in the project root directory. -
Add the following environment variables:
FLASK_ENV=development CORPID=your-corporate-id AGENTID=your-agent-id CORPSECRET=your-corporate-secret ADMINURL=https://xxxxxxx
-
-
Set up the configure file for development environment:
-
Create a
config_development.py
file in the project root directory. -
Add the following variables:
MONGO_URI=your-mongodb-uri
-
-
Run the application:
flask run
Contributions are welcome! Please feel free to submit a pull request or open an issue if you find a bug or have a suggestion for a new feature.
This project is licensed under the MIT License.