Welcome to the documentation for my project, which includes a Flask sever and a parser (extra: test client). This documentation will guide you through the installation and usage of the project components.
To get started with the project, follow these installation steps:
- Clone the repository:
git clone https://github.com/cutecei/flask_api_endpoints.git
- Navigate to the project directory:
cd flask_api_endpoints
- Install the project dependencies:
pip install -r requirements.txt
-
Run MongoDB server Make sure you have created facct collection
-
Run server
python flask_server.py
This project has method: POST and GET
-
POST:
Allows the client to add data to MongoDB. Also there is a parser that checks the data to see if it matches the required format and if the fields are not empty.
def send_json(json_file):
with open(json_file, "r") as file:
send_data = json.load(file)
response = requests.post(url_post, json=send_data)
print(response.text)
-
GET:
Allows the client to retrieve data from MongoDB. Also client can add params for advanced search.
def get_data():
params = {
"malwareList": ["Lockbit"]
}
response = requests.get(url_get, params=params)
print(response.json())
or
def get_data():
params = {
"dateFirstSeen": "2023-09-30T11:03:52+00:00",
"dateLastSeen": "2023-09-30T11:03:52+00:00"
}
response = requests.get(url_get, params=params)
print(response.json())