Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
Dishly
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
O Bar da Lora
Dishly
Commits
a5664ca4
Commit
a5664ca4
authored
May 07, 2026
by
Natã Frederico Sangalletti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app.py corrigido (V0.1)
parent
c382d123
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
152 deletions
+39
-152
app.py
app/app.py
+11
-12
cadastro.html
templates/cadastro.html
+8
-82
editar.html
templates/editar.html
+10
-2
index.html
templates/index.html
+10
-56
No files found.
app/app.py
View file @
a5664ca4
...
@@ -13,12 +13,7 @@ db = SQLAlchemy(app)
...
@@ -13,12 +13,7 @@ db = SQLAlchemy(app)
# Modelo da Tabela
# Modelo da Tabela
class
Receita
(
db
.
Model
):
class
Receita
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
nome
=
db
.
Column
(
db
.
String
(
100
))
nome
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
)
porcoes
=
db
.
Column
(
db
.
Integer
)
tempo
=
db
.
Column
(
db
.
Integer
)
descricao
=
db
.
Column
(
db
.
String
(
100
))
ingredientes
=
db
.
Column
(
db
.
String
(
500
))
preparo
=
db
.
Column
(
db
.
String
(
700
))
@app.route
(
'/'
)
@app.route
(
'/'
)
def
index
():
def
index
():
...
@@ -29,18 +24,22 @@ def index():
...
@@ -29,18 +24,22 @@ def index():
def
cadastro
():
def
cadastro
():
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
nova
=
Receita
(
nova
=
Receita
(
nome
=
request
.
form
[
'nome'
],
nome
=
request
.
form
[
'nome'
]
porcoes
=
request
.
form
[
'porcoes'
],
tempo
=
request
.
form
[
'tempo'
],
descricao
=
request
.
form
[
'descricao'
],
ingredientes
=
request
.
form
[
'ingredientes'
],
preparo
=
request
.
form
[
'preparo'
]
)
)
db
.
session
.
add
(
nova
)
db
.
session
.
add
(
nova
)
db
.
session
.
commit
()
db
.
session
.
commit
()
return
redirect
(
url_for
(
'index'
))
return
redirect
(
url_for
(
'index'
))
return
render_template
(
'cadastro.html'
)
return
render_template
(
'cadastro.html'
)
@app.route
(
'/editar/<int:id>'
,
methods
=
[
'GET'
,
'POST'
])
def
editar
(
id
):
receita
=
Receita
.
query
.
get_or_404
(
id
)
if
request
.
method
==
'POST'
:
receita
.
nome
=
request
.
form
[
'nome'
]
db
.
session
.
commit
()
return
redirect
(
url_for
(
'index'
))
return
render_template
(
'editar.html'
,
receita
=
receita
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
with
app
.
app_context
():
with
app
.
app_context
():
db
.
create_all
()
db
.
create_all
()
...
...
templates/cadastro.html
View file @
a5664ca4
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"pt-BR"
>
<html
lang=
"pt-BR"
>
<head>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
rel=
"stylesheet"
href=
"{{ url_for('static', filename='style.css') }}"
>
<title>
Cadastro
</title>
<link
rel=
"preconnect"
href=
"https://fonts.googleapis.com"
>
<link
rel=
"preconnect"
href=
"https://fonts.gstatic.com"
crossorigin
>
<link
href=
"https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap"
rel=
"stylesheet"
>
<title>
Dishly
</title>
</head>
</head>
<body>
<body>
<h1>
Cadastro com Imagem
</h1>
<div>
<form
action=
"/cadastro"
method=
"POST"
>
<div
class=
"actions"
>
<label
for=
"nome"
>
Nome da Receita
</label>
<a
href=
"/"
class=
"btn btn-primary"
>
Voltar
</a>
<input
id=
"nome"
name=
"nome"
type=
"text"
required
>
</div>
<button
type=
"reset"
>
Limpar
</button>
<button
type=
"submit"
>
Salvar
</button>
<form
id=
"formCadastro"
action=
"{{ url_for('cadastro') }}"
method=
"post"
>
<input
type=
"text"
id=
"nome"
name=
"nome"
placeholder=
"Digite o nome"
required
><br>
<input
type=
"text"
id=
"porcoes"
name=
"porcoes"
placeholder=
"Porções"
required
><br>
<input
type=
"text"
id=
"tempo"
name=
"tempo"
placeholder=
"Tempo de preparo"
required
><br>
<textarea
id=
"descricao"
name=
"descricao"
placeholder=
"Descrição da receita"
required
></textarea><br>
<input
type=
"text"
id=
"ad_ingrediente"
placeholder=
"Ingrediente"
>
<button
type=
"button"
onclick=
"adicionar()"
>
Adicionar
</button>
<br><br>
<textarea
id=
"ingredientes"
name=
"ingredientes"
rows=
"10"
cols=
"30"
readonly
required
></textarea><br>
<script>
function
adicionar
()
{
let
texto
=
document
.
getElementById
(
"ad_ingrediente"
).
value
;
let
textarea
=
document
.
getElementById
(
"ingredientes"
);
if
(
!
texto
)
return
;
textarea
.
value
+=
"- "
+
texto
+
"
\
n"
;
document
.
getElementById
(
"ad_ingrediente"
).
value
=
""
;
}
</script>
<textarea
id=
"preparo"
name=
"preparo"
placeholder=
"Modo de preparo"
required
></textarea><br>
<input
type=
"submit"
value=
"Cadastrar"
class=
"btn btn-primary"
><br>
<button
type=
"reset"
>
Apagar Dados
</button>
</form>
</form>
</div>
<div
class=
"cards"
id=
"lista"
></div>
<script>
const
form
=
document
.
getElementById
(
"formCadastro"
);
const
lista
=
document
.
getElementById
(
"lista"
);
form
.
addEventListener
(
"submit"
,
function
(
e
)
{
e
.
preventDefault
();
const
nome
=
document
.
getElementById
(
"nome"
).
value
;
const
arquivo
=
document
.
getElementById
(
"imagem"
).
files
[
0
];
if
(
!
arquivo
)
return
;
const
leitor
=
new
FileReader
();
leitor
.
onload
=
function
(
evento
)
{
const
card
=
document
.
createElement
(
"div"
);
card
.
classList
.
add
(
"card"
);
card
.
innerHTML
=
`
<img src="
${
evento
.
target
.
result
}
">
<h3>
${
nome
}
</h3>
`
;
lista
.
appendChild
(
card
);
form
.
reset
();
};
leitor
.
readAsDataURL
(
arquivo
);
});
</script>
</body>
</body>
</html>
</html>
\ No newline at end of file
templates/editar.html
View file @
a5664ca4
...
@@ -3,9 +3,16 @@
...
@@ -3,9 +3,16 @@
<head>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Document
</title>
<title>
Editar Receita
</title>
</head>
</head>
<body>
<body>
<div>
<form
action=
"/editar/{{ receita.id }}"
method=
"POST"
>
<label
for=
"nome"
>
Nome da Receita
</label>
<input
id=
"nome"
name=
"nome"
type=
"text"
value=
"{{ receita.nome }}"
required
>
<button
type=
"reset"
>
Limpar
</button>
<button
type=
"submit"
>
Salvar
</button>
</form>
</div>
</body>
</body>
</html>
</html>
\ No newline at end of file
templates/index.html
View file @
a5664ca4
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"PT-br"
>
<html
lang=
"pt-BR"
>
<head>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
rel=
"stylesheet"
href=
"{{ url_for('static', filename='style.css') }}"
>
<link
rel=
"preconnect"
href=
"https://fonts.googleapis.com"
>
<link
rel=
"preconnect"
href=
"https://fonts.gstatic.com"
crossorigin
>
<link
href=
"https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap"
rel=
"stylesheet"
>
<title>
Dishly
</title>
<title>
Dishly
</title>
</head>
</head>
<body>
<body>
<div
class=
"container"
>
<a
href=
"/cadastro"
>
Cadastrar Receita
</a>
<header>
<h1>
Lista de Receitas
</h1>
<h1>
Receitas
</h1>
<ul>
<p
class=
"subtitle"
>
Gerenciamento de receitas
</p>
{% for receita in receitas %}
</header>
<li>
{{ receita.nome }}
<div
class=
"actions"
>
<a
href=
"/editar/{{ receita.id }}"
>
Editar
</a>
<a
href=
"/cadastro"
class=
"btn btn-primary"
>
➕ Nova Receita
</a>
</li>
</div>
{% if receitas %}
<div
class=
"table-responsive"
>
<table
class=
"receitas-table"
>
<thead>
<tr>
<th>
Nome
</th>
<th>
Porções
</th>
<th>
Tempo
</th>
<th>
Descrição
</th>
<th>
Ingredientes
</th>
<th>
Preparo
</th>
</tr>
</thead>
<tbody>
{% for a in receitas %}
<tr>
<td><strong>
{{ a.nome }}
</strong></td>
<td>
{{ a.porcoes }} porções
</td>
<td>
{{ a.tempo }} minutos
</td>
<td>
{{ a.descricao }}
</td>
<td>
{{ a.ingredientes }}
</td>
<td>
{{ a.preparo }}
</td>
<td
class=
"actions-column"
>
<a
href=
"/editar/{{ a.id }}"
class=
"btn btn-edit"
>
✏️ Editar
</a>
<a
href=
"/delete/{{ a.id }}"
class=
"btn btn-delete"
onclick=
"return confirm('Tem certeza que deseja deletar?')"
>
🗑️ Deletar
</a>
</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</ul>
</table>
</div>
{% else %}
<div
class=
"empty-state"
>
<p>
Nenhuma receita cadastrada ainda.
</p>
<a
href=
"/cadastro"
class=
"btn btn-primary"
>
Cadastre a primeira receita
</a>
</div>
{% endif %}
</div>
</body>
</body>
</html>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment