Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dockerfile #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 129 additions & 129 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,129 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python:3.13.0
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . /app/
EXPOSE 5000
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
114 changes: 57 additions & 57 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
from flask import Flask, render_template, request
import logging
import socket # Módulo para obter informações do servidor

app = Flask(__name__,
static_url_path='',
static_folder='static',
template_folder='templates')

@app.route('/', methods=['GET', 'POST'])
def index():
# Obter informações do servidor
hostname = socket.gethostname()
ip_address = socket.gethostbyname(hostname)

if request.method == 'GET':
return render_template('index.html', hostname=hostname, ip_address=ip_address)
else:
selecao = request.form.get('selectTemp')
valor = request.form.get('valorRef')

try:
valor = float(valor)
except ValueError:
return render_template('index.html', conteudo={'unidade': 'inválido', 'valor': 'Entrada inválida'}, hostname=hostname, ip_address=ip_address)

# Lógica de conversão
if selecao == '1': # Metro para Quilômetros
resultado = valor / 1000
unidade = "quilômetros"
elif selecao == '2': # Quilômetros para Metro
resultado = valor * 1000
unidade = "metros"
elif selecao == '3': # Metro para Milhas
resultado = valor / 1609.34
unidade = "milhas"
elif selecao == '4': # Milhas para Metro
resultado = valor * 1609.34
unidade = "metros"
elif selecao == '5': # Metro para Pés
resultado = valor * 3.28084
unidade = "pés"
elif selecao == '6': # Pés para Metro
resultado = valor / 3.28084
unidade = "metros"
else:
resultado = "Inválido"
unidade = ""

return render_template('index.html', conteudo={'unidade': unidade, 'valor': resultado}, hostname=hostname, ip_address=ip_address)

if __name__ == '__main__':
app.run()
else:
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)
from flask import Flask, render_template, request
import logging
import socket # Módulo para obter informações do servidor
app = Flask(__name__,
static_url_path='',
static_folder='static',
template_folder='templates')
@app.route('/', methods=['GET', 'POST'])
def index():
# Obter informações do servidor
hostname = socket.gethostname()
ip_address = socket.gethostbyname(hostname)
if request.method == 'GET':
return render_template('index.html', hostname=hostname, ip_address=ip_address)
else:
selecao = request.form.get('selectTemp')
valor = request.form.get('valorRef')
try:
valor = float(valor)
except ValueError:
return render_template('index.html', conteudo={'unidade': 'inválido', 'valor': 'Entrada inválida'}, hostname=hostname, ip_address=ip_address)
# Lógica de conversão
if selecao == '1': # Metro para Quilômetros
resultado = valor / 1000
unidade = "quilômetros"
elif selecao == '2': # Quilômetros para Metro
resultado = valor * 1000
unidade = "metros"
elif selecao == '3': # Metro para Milhas
resultado = valor / 1609.34
unidade = "milhas"
elif selecao == '4': # Milhas para Metro
resultado = valor * 1609.34
unidade = "metros"
elif selecao == '5': # Metro para Pés
resultado = valor * 3.28084
unidade = "pés"
elif selecao == '6': # Pés para Metro
resultado = valor / 3.28084
unidade = "metros"
else:
resultado = "Inválido"
unidade = ""
return render_template('index.html', conteudo={'unidade': unidade, 'valor': resultado}, hostname=hostname, ip_address=ip_address)
if __name__ == '__main__':
app.run()
else:
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading