This is a simple Flask app that interacts with a MySQL database. The app allows users to submit messages, which are then stored in the database and displayed on the frontend.
Before you begin, make sure you have the following installed:
- Git (optional, for cloning the repository)
- EC2 insatnce
-
Clone this repository (if you haven't already):
git clone https://github.com/your-username/your-repo-name.git
-
Navigate to the project directory:
cd your-repo-name -
Create a
.envfile in the project directory to store your MySQL environment variables:touch .env
-
Open the
.envfile and add your MySQL configuration:MYSQL_HOST=mysql MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DB=your_database
-
Update System and Install Required Packages:
sudo apt update && sudo apt upgrade -y sudo apt install python3-pip python3-venv mysql-server -y -
Access the Flask app in your web browser:
- http://ec2-instance_ip:5000-
Create the
messagestable in your MySQL database:-
Use a MySQL client or tool (e.g., phpMyAdmin) to execute the following SQL commands:
CREATE TABLE messages ( id INT AUTO_INCREMENT PRIMARY KEY, message TEXT );
-
-
Run the Flask App:
python app.py --host=0.0.0.0 --port=5000
-
Interact with the app:
- Visit http://ec2-instance-ip to see the frontend. You can submit new messages using the form.
-
Make sure to replace placeholders (e.g.,
your_username,your_password,your_database) with your actual MySQL configuration. -
This is a basic setup for demonstration purposes. In a production environment, you should follow best practices for security and performance.
-
Be cautious when executing SQL queries directly. Validate and sanitize user inputs to prevent vulnerabilities like SQL injection.
This project is open-source and available under the MIT License.
For questions, feedback, or contributions, feel free to open an issue or submit a pull request.