Add Installation and Setup Guide
parent
43a02dccd6
commit
09c4c1118a
131
Installation-and-Setup-Guide.md
Normal file
131
Installation-and-Setup-Guide.md
Normal file
@ -0,0 +1,131 @@
|
||||
# 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**
|
||||
|
||||
1. **Operating System**: Linux (Tested on Ubuntu/Debian).
|
||||
2. **Python**: Python 3.8 or higher.
|
||||
3. **MySQL**: MySQL server installed and running.
|
||||
|
||||
---
|
||||
|
||||
## **Step 1: Install System Dependencies**
|
||||
|
||||
### **1.1 Install Python and pip**
|
||||
Ensure Python and pip are installed:
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install python3 python3-pip
|
||||
```
|
||||
|
||||
### **1.2 Install MySQL Server**
|
||||
Install MySQL server and client:
|
||||
```bash
|
||||
sudo apt-get install mysql-server mysql-client
|
||||
```
|
||||
|
||||
### **1.3 Install MySQL Development Libraries**
|
||||
Install the MySQL development libraries required for `mysqlclient`:
|
||||
```bash
|
||||
sudo apt-get install libmysqlclient-dev
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## **Step 2: Install Python Dependencies**
|
||||
|
||||
Install the required Python packages using pip:
|
||||
```bash
|
||||
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:
|
||||
```bash
|
||||
sudo mysql -u root -p
|
||||
```
|
||||
|
||||
### **3.2 Create a Database**
|
||||
Create a new database for the application:
|
||||
```sql
|
||||
CREATE DATABASE asset_test_db;
|
||||
```
|
||||
|
||||
### **3.3 Create a User**
|
||||
Create a new user and grant privileges to the database:
|
||||
```sql
|
||||
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):
|
||||
```bash
|
||||
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:
|
||||
```python
|
||||
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:
|
||||
```bash
|
||||
python3 app.py
|
||||
```
|
||||
|
||||
The application will be available at `http://localhost:5000`.
|
||||
|
||||
---
|
||||
|
||||
## **Step 5: Access the Application**
|
||||
|
||||
1. Open a web browser and navigate to `http://localhost:5000`.
|
||||
2. Log in using the default credentials (if applicable).
|
||||
3. Use the application to manage inventory items.
|
||||
|
||||
---
|
||||
|
||||
## **Troubleshooting**
|
||||
|
||||
### **1. MySQL Connection Issues**
|
||||
- Ensure the MySQL server is running:
|
||||
```bash
|
||||
sudo systemctl status mysql
|
||||
```
|
||||
- Verify the database and user credentials in `config.py`.
|
||||
|
||||
### **2. Missing Python Packages**
|
||||
- Ensure all required packages are installed:
|
||||
```bash
|
||||
pip install flask flask-sqlalchemy flask-session marshmallow python-dotenv
|
||||
```
|
||||
|
||||
### **3. Permission Denied Errors**
|
||||
- Ensure the MySQL user has the correct privileges:
|
||||
```sql
|
||||
GRANT ALL PRIVILEGES ON asset_test_db.* TO 'assetadmin'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
```
|
||||
|
||||
---
|
Loading…
Reference in New Issue
Block a user