| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is a Python Flask application that provides various API routes for user registration, login, and profile update actions.
The application uses MongoDB for storing user data and Flask JWT-Extended for handling JWT-based authentication.
Application configuration variables are declared in a .env file. Here's a sample .env file:
FLASK_APP=app FLASK_ENV=development MONGO_URL=mongodb://localhost:27017 MONGO_DB=test JWT_SECRET_KEY=secret123
Key configuration variables include:
Clone the repository
git clone https://github.com/CrACK000/easy-python-backend-app.git
Install the requirements
pip install -r requirements.txt
Run the application
flask run
Access the apis at http://localhost:5000 to register, login or perform other actions.
This Python Flask API provides different endpoints for managing user registration, login, and profile updates. The API can be tested using different tools like Postman, cURL etc. In this documentation, we demonstrate how to test the API using the Postman tool.
Before testing, ensure that you are running your application locally. Refer to the main README.md for the instructions on how to run the application.
A Postman collection called postman_collection.json is included in the root directory of this project's GitHub repository. This collection includes the requests needed to test the user registration, login, profile checking and profile updates.
To use this collection:
The collection should be imported into Postman, and you can use it to test the different endpoints.
This endpoint is used to register a new user. The request should include username, password and email in the form data.
This endpoint is used to login a user. The request should include username and password in the form data. On successful login, it returns a JWT access token, remember to replace it with <NEW_TOKEN> for the following requests.
This endpoint is used to verify the user's JWT access token is valid or not. Replace <NEW_TOKEN> with the token rendered after user login.
This endpoint is used to updated the username of the user. Replace <NEW_TOKEN> with the token rendered after user login. new_username is the username you want to update to.
The JWT token obtained from the /login endpoint will be used in the Authorization header for the /checkAuth and /editProfile requests as Bearer <NEW_TOKEN>. Note that this token will expire according to the expiration time set in your application (default is 15 minutes), so if your testing takes longer than that, you will need to login again to get a new token.
If the token expires or is otherwise incorrect, the server will respond with a 401 error. This means "unauthorized", so if you see this, you know you need to check your authorization header.
This application is a simple Flask application that has been Dockerized for consistency across different environments.
To build the Docker image, navigate to the directory containing the Dockerfile and run:
docker build -t my-app .
Replace "my-app" with the name you want to assign to the Docker image.
To run the image, enter:
docker run -p 5000:5000 my-app
Replace "my-app" with the name of the Docker image you created. This will start a Docker container from the image and bind it to port 5000.
Once the Docker container is running, you can test the application by navigating to http://localhost:5000 in your web browser.
To stop a running Docker container, first determine the container ID by running:
docker ps
Then, stop the container by running:
docker stop <CONTAINER_ID>
Replace <CONTAINER_ID> with the actual container ID.
Remember to stop the Docker container when you're finished to free up system resources.
| Back | FazBrowse Home | New Git URL |