fabrice.regnier
2 weeks ago
5 changed files with 35 additions and 0 deletions
@ -1 +1,3 @@ |
|||
yo, ceci est l'api de kaz ! |
|||
|
|||
Je pars de ça: python api + docker-compose: https://dev.to/alissonzampietro/the-amazing-journey-of-docker-compose-17lj |
|||
|
@ -0,0 +1,7 @@ |
|||
FROM python:3.11 |
|||
RUN mkdir /usr/src/app/ |
|||
COPY . /usr/src/app/ |
|||
WORKDIR /usr/src/app/ |
|||
EXPOSE 5000 |
|||
RUN pip install -r requirements.txt |
|||
CMD ["python", "app.py"] |
@ -0,0 +1,14 @@ |
|||
import os |
|||
from flask import Flask, jsonify |
|||
app = Flask(__name__) |
|||
|
|||
#we define the route / |
|||
@app.route('/') |
|||
def welcome(): |
|||
# return a json |
|||
return jsonify({'status': 'api working'}) |
|||
|
|||
if __name__ == '__main__': |
|||
#define the localhost ip and the port that is going to be used |
|||
# in some future article, we are going to use an env variable instead a hardcoded port |
|||
app.run(host='0.0.0.0', port=os.getenv('PORT')) |
@ -0,0 +1 @@ |
|||
flask |
@ -0,0 +1,11 @@ |
|||
version: '3.8' |
|||
services: |
|||
api-service: |
|||
build: ./api-kaz/ |
|||
volumes: |
|||
- ./api-kaz/:/usr/src/app/ |
|||
ports: |
|||
- 5000:5000 |
|||
environment: |
|||
PORT: 5000 |
|||
FLASK_DEBUG: 1 |
Loading…
Reference in new issue