Page:
Installation and Setup Guide
1
Installation and Setup Guide
Candifloss edited this page 2025-03-08 07:37:59 +00:00
Installation and Setup Guide
This guide provides step-by-step instructions for installing and running the Flask CRUD application. It covers installing dependencies, setting up the database, and running the application.
Prerequisites
- Operating System: Linux (Tested on Ubuntu/Debian).
- Python: Python 3.8 or higher.
- MySQL: MySQL server installed and running.
Step 1: Install System Dependencies
1.1 Install Python and pip
Ensure Python and pip are installed:
sudo apt-get update
sudo apt-get install python3 python3-pip
1.2 Install MySQL Server
Install MySQL server and client:
sudo apt-get install mysql-server mysql-client
1.3 Install MySQL Development Libraries
Install the MySQL development libraries required for mysqlclient
:
sudo apt-get install libmysqlclient-dev
Step 2: Install Python Dependencies
Install the required Python packages using pip:
pip install flask flask-sqlalchemy flask-session marshmallow python-dotenv
Step 3: Set Up the MySQL Database
3.1 Log in to MySQL
Log in to the MySQL server as the root user:
sudo mysql -u root -p
3.2 Create a Database
Create a new database for the application:
CREATE DATABASE asset_test_db;
3.3 Create a User
Create a new user and grant privileges to the database:
CREATE USER 'assetadmin'@'localhost' IDENTIFIED BY '1234';
GRANT ALL PRIVILEGES ON asset_test_db.* TO 'assetadmin'@'localhost';
FLUSH PRIVILEGES;
Step 4: Run the Application
4.1 Clone the Repository
Clone the project repository (if not already done):
git clone https://git.candifloss.cc/candifloss/flask_crud_app.git
cd flask_crud_app
4.2 Configure the Application
Edit the config.py
file to ensure the MySQL connection details match your setup:
class sql_conf:
SQL_USER = "assetadmin"
SQL_PASSWORD = "1234"
SQL_HOST = "localhost"
SQL_DB = "asset_test_db"
SQL_TABLE = "asset_test"
4.3 Run the Application
Start the Flask development server:
python3 app.py
The application will be available at http://localhost:5000
.
Step 5: Access the Application
- Open a web browser and navigate to
http://localhost:5000
. - Log in using the default credentials (if applicable).
- Use the application to manage inventory items.
Troubleshooting
1. MySQL Connection Issues
- Ensure the MySQL server is running:
sudo systemctl status mysql
- Verify the database and user credentials in
config.py
.
2. Missing Python Packages
- Ensure all required packages are installed:
pip install flask flask-sqlalchemy flask-session marshmallow python-dotenv
3. Permission Denied Errors
- Ensure the MySQL user has the correct privileges:
GRANT ALL PRIVILEGES ON asset_test_db.* TO 'assetadmin'@'localhost'; FLUSH PRIVILEGES;