Téléverser les fichiers vers "Web"
This commit is contained in:
parent
35de0f98ca
commit
08358252fa
10
Web/Dockerfile
Normal file
10
Web/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM python:3.9
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt requirements.txt
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
CMD ["python", "app.py"]
|
BIN
Web/Dockerfile~
Normal file
BIN
Web/Dockerfile~
Normal file
Binary file not shown.
28
Web/app.py
Normal file
28
Web/app.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from flask import Flask
|
||||||
|
import os
|
||||||
|
import psycopg2
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://user:password@db:5432/mydatabase")
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def home():
|
||||||
|
return "This is my application!"
|
||||||
|
|
||||||
|
@app.route('/db-test')
|
||||||
|
def db_test():
|
||||||
|
try:
|
||||||
|
conn = psycopg2.connect(DATABASE_URL)
|
||||||
|
cur = conn.cursor()
|
||||||
|
cur.execute("SELECT 'Database connection successful!'")
|
||||||
|
message = cur.fetchone()[0]
|
||||||
|
cur.close()
|
||||||
|
conn.close()
|
||||||
|
return message
|
||||||
|
except Exception as e:
|
||||||
|
return f"Database connection failed: {e}"
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0', port=5000)
|
||||||
|
|
2
Web/requirements.txt
Normal file
2
Web/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
flask
|
||||||
|
psycopg2
|
Loading…
Reference in New Issue
Block a user