Téléverser les fichiers vers "/"

This commit is contained in:
Coline Reberga 2025-03-16 10:19:36 +00:00
commit 92319bc1d7
5 changed files with 122 additions and 0 deletions

60
README.md Normal file
View File

@ -0,0 +1,60 @@
# My Blog Application
## Description
This is a blog application where users can add and delete articles easily. The application consists of a form to add articles on the left side and a list of existing articles on the right side.
## Features
- Add a new article by entering a title and content.
- View all articles in a clean and structured layout.
- Delete an article with a single click.
## Installation & Setup
### Requirements
- Docker
- Docker Compose
### Steps to Run the Application
1. Clone the repository:
```bash
git clone <repository_url>
cd z1
```
2. Prepare the application:
```bash
./prepare-app.sh
```
3. Start the application:
```bash
./start-app.sh
```
4. Open a web browser and go to:
```
http://localhost:5000
```
### Stopping the Application
To stop the application, run:
```bash
./stop-app.sh
```
### Removing the Application
To completely remove all data and configurations, run:
```bash
./remove-app.sh
```
## Technology Stack
- **Backend**: Flask (Python)
- **Database**: PostgreSQL
- **Frontend**: HTML + CSS (Embedded in Flask)
- **Containerization**: Docker & Docker Compose
## How It Works
- When an article is added, it is stored in a PostgreSQL database.
- The articles are displayed dynamically on the page.
- The delete button allows users to remove articles from the database.
## Contact
If you have any issues, feel free to open an issue or contribute to the project!

15
prepare-app.sh Normal file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
echo "Start of preparation"
# Create the volume.
docker volume create pgdata
# Create the Docker network.
docker network create app_network
# Create the Flask application
docker build -t flask_app_image ./app
echo "Preparation done"

13
remove-app.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
echo "Remove the application"
docker rm -f flask_app postgres_db
# Remove the network and volume
docker network rm app_network
docker volume rm pgdata
echo "Application removed."

27
start-app.sh Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -e
echo "Start the application"
# Run PostgreSQL container
docker run -d --name postgres_db \
--network app_network \
-e 'POSTGRES_USER=user' \
-e 'POSTGRES_PASSWORD=password' \
-e 'POSTGRES_DB=sampledb' \
-v pgdata:/var/lib/postgresql/data \
--restart unless-stopped \
postgres:13
# Run Flask application container
docker run -d --name flask_app \
--network app_network \
-p 5000:5000 \
-e 'DB_HOST=postgres_db' \
-e 'POSTGRES_USER=user' \
-e 'POSTGRES_PASSWORD=password' \
-e 'POSTGRES_DB=sampledb' \
--restart unless-stopped \
flask_app_image
echo "The application is available at http://localhost:5000"

7
stop-app.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
echo "Stop the application..."
docker stop flask_app postgres_db
echo "Application stopped."