This is a simple Flask project that allows users to upload files to a MySQL database. Each uploaded file is stored in the database.
-
Clone the repository:
git clone https://github.com/Tnvj/Flask-Form cd Flask-Form
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install dependencies:
pip install Flask Flask-MySQLdb python-dotenv
-
Set up environment variables:
Create a
.env
file in the root directory of the project:MYSQL_HOST=your_mysql_host MYSQL_USER=your_mysql_user MYSQL_PASSWORD=your_mysql_password MYSQL_DB=your_mysql_db UPLOAD_FOLDER=uploads
Adjust the values according to your MySQL setup.
-
Initialize the MySQL database:
- Create a MySQL database with the name specified in your
.env
file. - Update the database configuration in
app.py
if necessary.
- Create a MySQL database with the name specified in your
-
Run the application:
python app.py
The application will start running on
http://localhost:5000
.
-
Upload Files:
-
View Uploaded Files:
- Flask
- Flask-MySQLdb
- python-dotenv