Containerzing our python application

Flask is a Python-based micro web platform. It is known as a microframework because it does not necessitate the use of any specific resources or libraries. It lacks a database abstraction layer, type validation, or any other components that rely on pre…


This content originally appeared on DEV Community and was authored by vishwasnarayanre

Flask is a Python-based micro web platform. It is known as a microframework because it does not necessitate the use of any specific resources or libraries. It lacks a database abstraction layer, type validation, or any other components that rely on pre-existing third-party libraries to perform basic functions.

this is just a boiler plate hello world program in python


#write this in  "flask_code,py"
from flask import Flask
app = FLask(__name__)

@app.route("/")
def hello_world_for_flask():
    return "first flask project"

app.run(port = 8090) #make it run in 8090 port

pip freeze on your command prompt will give all the installed packages on your enviroement thus you can go and add them and this command also give the version of the installed.After they list in the terminal put all the text here to the requirements.txt and save it in the directory that has Dockerfile.

FROM python:3

#make the workdir command to app
WORKDIR /app

#install depedencies from here
COPY requirements.txt .
RUN pip install -r requirements.txt

#we have the copy our source code

COPY /app .

#to run our application
CMD ["python", "flask_code.py"]

Then after building the docker file please do use the below command to build the docker file.

docker build -t docker_built_file

After building the docker image do go and run it with the command that I have stated here(you can use any port that you wish to use).

docker run -p 8090:8090 docker_built_file

Then go to the browser and type localhost:8090 and then you will find this as the output.(if you have worked as stated here).

Alt Text

Thank you all hope this helps you all in learning new thing.


This content originally appeared on DEV Community and was authored by vishwasnarayanre


Print Share Comment Cite Upload Translate Updates
APA

vishwasnarayanre | Sciencx (2021-05-08T17:11:39+00:00) Containerzing our python application. Retrieved from https://www.scien.cx/2021/05/08/containerzing-our-python-application/

MLA
" » Containerzing our python application." vishwasnarayanre | Sciencx - Saturday May 8, 2021, https://www.scien.cx/2021/05/08/containerzing-our-python-application/
HARVARD
vishwasnarayanre | Sciencx Saturday May 8, 2021 » Containerzing our python application., viewed ,<https://www.scien.cx/2021/05/08/containerzing-our-python-application/>
VANCOUVER
vishwasnarayanre | Sciencx - » Containerzing our python application. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/08/containerzing-our-python-application/
CHICAGO
" » Containerzing our python application." vishwasnarayanre | Sciencx - Accessed . https://www.scien.cx/2021/05/08/containerzing-our-python-application/
IEEE
" » Containerzing our python application." vishwasnarayanre | Sciencx [Online]. Available: https://www.scien.cx/2021/05/08/containerzing-our-python-application/. [Accessed: ]
rf:citation
» Containerzing our python application | vishwasnarayanre | Sciencx | https://www.scien.cx/2021/05/08/containerzing-our-python-application/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.