├── .gitignore ├── README.md ├── docker-compose.yml ├── requirements.txt ├── .dockerignore ├── docker-compose.debug.yml ├── .vscode ├── launch.json └── tasks.json ├── Dockerfile ├── app.py └── templates ├── contact.html └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.json 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flask 2 | Python Flask project from Udemy with Docker 3 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | flaskudemy: 5 | image: flaskudemy 6 | build: 7 | context: . 8 | dockerfile: ./Dockerfile 9 | ports: 10 | - 5002:5002 11 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # To ensure app dependencies are ported from your virtual environment/host machine into your container, run 'pip freeze > requirements.txt' in the terminal to overwrite this file 2 | flask==2.2.2 3 | gunicorn==20.1.0 4 | gspread -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | **/__pycache__ 2 | **/.venv 3 | **/.classpath 4 | **/.dockerignore 5 | **/.env 6 | **/.git 7 | **/.gitignore 8 | **/.project 9 | **/.settings 10 | **/.toolstarget 11 | **/.vs 12 | **/.vscode 13 | **/*.*proj.user 14 | **/*.dbmdl 15 | **/*.jfm 16 | **/bin 17 | **/charts 18 | **/docker-compose* 19 | **/compose* 20 | **/Dockerfile* 21 | **/node_modules 22 | **/npm-debug.log 23 | **/obj 24 | **/secrets.dev.yaml 25 | **/values.dev.yaml 26 | LICENSE 27 | README.md 28 | -------------------------------------------------------------------------------- /docker-compose.debug.yml: -------------------------------------------------------------------------------- 1 | version: '3.4' 2 | 3 | services: 4 | flaskudemy: 5 | image: flaskudemy 6 | build: 7 | context: . 8 | dockerfile: ./Dockerfile 9 | command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 -m flask run --no-debugger --no-reload --host 0.0.0.0 --port 5002"] 10 | ports: 11 | - 5002:5002 12 | - 5678:5678 13 | environment: 14 | - FLASK_APP=app.py 15 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Docker: Python - Flask", 5 | "type": "docker", 6 | "request": "launch", 7 | "preLaunchTask": "docker-run: debug", 8 | "python": { 9 | "pathMappings": [ 10 | { 11 | "localRoot": "${workspaceFolder}", 12 | "remoteRoot": "/app" 13 | } 14 | ], 15 | "projectType": "flask" 16 | } 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "docker-build", 6 | "label": "docker-build", 7 | "platform": "python", 8 | "dockerBuild": { 9 | "tag": "flaskudemy:latest", 10 | "dockerfile": "${workspaceFolder}/Dockerfile", 11 | "context": "${workspaceFolder}", 12 | "pull": true 13 | } 14 | }, 15 | { 16 | "type": "docker-run", 17 | "label": "docker-run: debug", 18 | "dependsOn": [ 19 | "docker-build" 20 | ], 21 | "dockerRun": { 22 | "env": { 23 | "FLASK_APP": "app.py", 24 | "FLASK_ENV": "development", 25 | }, 26 | "volumes": [ 27 | { 28 | "containerPath": "/app", 29 | "localPath": "${workspaceFolder}" 30 | 31 | } 32 | ] 33 | }, 34 | "python": { 35 | "args": [ 36 | "run", 37 | "--host", 38 | "0.0.0.0", 39 | "--port", 40 | "5002" 41 | ], 42 | "module": "flask" 43 | } 44 | } 45 | ] 46 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # For more information, please refer to https://aka.ms/vscode-docker-python 2 | FROM python:3.10-slim 3 | 4 | EXPOSE 5002 5 | 6 | # Keeps Python from generating .pyc files in the container 7 | ENV PYTHONDONTWRITEBYTECODE=1 8 | 9 | # Turns off buffering for easier container logging 10 | ENV PYTHONUNBUFFERED=1 11 | 12 | # Install pip requirements 13 | COPY requirements.txt . 14 | RUN python -m pip install -r requirements.txt 15 | 16 | WORKDIR /app 17 | COPY . /app 18 | 19 | # Creates a non-root user with an explicit UID and adds permission to access the /app folder 20 | # For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers 21 | RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app 22 | USER appuser 23 | 24 | # During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug 25 | CMD ["gunicorn", "--bind", "0.0.0.0:5002", "app:app"] 26 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import gspread 2 | from flask import Flask, render_template,request 3 | app = Flask(__name__) 4 | 5 | gc = gspread.service_account(filename='flask-Udemy.json') 6 | sh = gc.open("ML Team Daily Updates") 7 | shDailyUpdates = sh.get_worksheet(0) 8 | shAutomatedTest = sh.get_worksheet(1) 9 | #shAutomatedTest.append_row(["31/5/23", "Test","SUBIN","Ongoing"]) 10 | @app.route('/') 11 | def home(): 12 | return "Hello World" 13 | 14 | @app.route('/index', methods=['GET', 'POST']) 15 | def index(): 16 | if request.method == 'POST': 17 | name = request.form['name'] 18 | email = request.form['email'] 19 | message = request.form['message'] 20 | shAutomatedTest.append_row([name, email, message]) 21 | return "Updated Successfully" 22 | profile = { 23 | "about": shAutomatedTest.acell('B1').value, 24 | "interests": shAutomatedTest.acell('B2').value, 25 | "experience": shAutomatedTest.acell('B3').value, 26 | "education": shAutomatedTest.acell('B4').value, 27 | } 28 | return render_template('index.html', profile=profile) 29 | 30 | @app.route('/contact') 31 | def contact(): 32 | return render_template('contact.html') -------------------------------------------------------------------------------- /templates/contact.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Aramis Update Page! 7 | 8 | 9 | 10 |
11 |
12 |
13 |
14 | 15 |
16 |
17 | 18 |
19 | 20 |
21 |
22 |
23 | 24 |
25 | 26 |
27 |
28 |
29 | 30 |
31 | 32 |
33 |
34 |
35 | 36 |
37 |
38 |
39 |
40 | 41 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Aramis Update Page! 7 | 8 | 9 | 10 |
11 |
12 | 13 |
14 |

Subin Vidhu

15 |

@subin-vidhu

16 | Contact 17 | Youtube 18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |

About

26 |

{{profile.about}}

27 |
28 |
29 | 35 |
36 |
37 |
38 |
39 |

Experience

40 |

{{profile.experience}}

41 |
42 |
43 |
44 |
45 |

Education

46 |

{{profile.education}}

47 |
48 |
49 |
50 |
51 |
52 | 53 |
54 | 55 | --------------------------------------------------------------------------------