Final Project: Python Flask API

Fork the Repository thirdygayares/keriderya-api

Clone Your Repository

python -m venv venv   #Create a Virtual Environment
venv\Sc
pip install -r requirements.txt
git clone https://github.com/JoshuaNato/keriderya-api-release-test-v1.0.1.git
FLASK_ENV=development
DATABASE_URL=mysql://avnadmin:{password}@{host}:{port}/{database name}
SECRET_KEY=your_secret_key

Add .env File
Create a Database in Aiven Dashboard

  • Update the .env file

Clone Your Repository

      export FLASK_APP=app.py
      export FLASK_ENV=production
        export DATABASE_URL=mysql://joshuanato12345.mysql.pythonanywhere-services.com/joshuanato$keriderya_db

Add Certificates

 db upgrade    #Database Migration
 python run.py     #Run the Application

The screenshot shows a successful POST request in Postman. Let me break it down:


1. Endpoint

The request was sent to:
https://joshuanato12345.pythonanywhere.com/users

This is the API endpoint for creating new users.


2. Method

The HTTP method used is POST, which is typically used for creating resources on the server.


3. Request Body

The body of the request is in JSON format, as indicated by the dropdown (raw > JSON).

The content of the body:

{
  "username": "joshua",
  "password": "password",
  "role": "username",
  "email": "natojoshua"
}
  • username: The username to be created.

  • password: The associated password.

  • role: Specifies the user role (in this case, "username").

  • email: An email address (though it looks like a placeholder).


4. Response

  • Status Code: 201 Created
    This indicates the resource was successfully created on the server.

  • Response Body:

{
  "username": "joshua",
  "password": "password",
  "role": "username",
  "email": "natojoshua",
  "id": 101
}
  • The response confirms the details of the created user and includes an additional property, id, which is likely the unique identifier for the newly created user in the database (id: 101).

5. Headers

Though not fully visible in the screenshot, headers like Content-Type: application/json are typically required for JSON-based POST requests.


This POST request was successful:

  • A new user (username: joshua) was created.

  • The API responded with a 201 Created status and returned the user data, including a unique id.

Let me know if you'd like further assistance!

http://127.0.0.1:5000/