This is a simple flask-mongo db app that can be used a base for future applications.
This is a sample Flask-MongoDB authentication application that provides user registration and login functionality using Flask-RESTx, MongoDB, and Flask-Bcrypt.
- User registration with validation for username and password
- Secure password storage using bcrypt
- User login with validation for username and password
- MongoDB database for storing user information
- Error handling and response formatting
- Logging for tracking application behavior
-
Clone the repository:
git clone https://github.com/your-username/flask-mongodb-auth-app.git
-
Change into the project directory:
cd flask-mongodb-auth-app
-
Install Poetry:
- Visit the Poetry installation guide for instructions on how to install Poetry.
-
Install the project dependencies using Poetry:
poetry install
-
Set up the MongoDB database:
- Install MongoDB and start the MongoDB server.
- Create a MongoDB database for the application.
- Update the MongoDB connection details in the URI.
-
Start the application:
poetry shell python app.py
-
The application should now be running on
http://localhost:5000
.
By using Poetry, you can manage the project's dependencies, virtual environment, and packaging all in one tool. Ensure that you have Poetry installed, and follow the updated installation instructions provided above.
Feel free to modify and customize this section based on your specific project requirements.
-
Register a new user:
- Endpoint:
/auth/register
- Method:
POST
- Request Body:
{ "username": "your-username", "password": "your-password" }
- Response:
{ "message": "User registered successfully" }
- Endpoint:
-
Login with an existing user:
- Endpoint:
/auth/login
- Method:
POST
- Request Body:
{ "username": "your-username", "password": "your-password" }
- Response:
{ "message": "User authenticated successfully" }
- Endpoint:
Endpoint | Method | Description |
---|---|---|
/auth/register |
POST | Register a new user |
/auth/login |
POST | Authenticate a user |
- Flask: Python web framework
- Flask-RESTx: Extension for building REST APIs with Flask
- MongoDB: NoSQL database
- Flask-Bcrypt: Password hashing library
- Werkzeug: Web server gateway interface (WSGI) utility library
Contributions to this project are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.