├── .gitignore ├── static ├── imagens │ ├── flower.gif │ ├── lisp.png │ ├── fractal.jpg │ ├── hal9000.jpg │ └── mandelbrotset.jpg └── style.css ├── requirements.txt ├── app.py ├── README.md ├── LICENSE ├── templates └── home.html └── posts.py /.gitignore: -------------------------------------------------------------------------------- 1 | .myvenv 2 | myvenv/ 3 | __pycache__/ 4 | -------------------------------------------------------------------------------- /static/imagens/flower.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/flower.gif -------------------------------------------------------------------------------- /static/imagens/lisp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/lisp.png -------------------------------------------------------------------------------- /static/imagens/fractal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/fractal.jpg -------------------------------------------------------------------------------- /static/imagens/hal9000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/hal9000.jpg -------------------------------------------------------------------------------- /static/imagens/mandelbrotset.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/mandelbrotset.jpg -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Click==7.0 2 | Flask==1.1.1 3 | itsdangerous==1.1.0 4 | Jinja2==2.11.3 5 | MarkupSafe==1.1.1 6 | Werkzeug==0.16.0 7 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template 2 | from posts import posts 3 | 4 | app = Flask(__name__) 5 | 6 | @app.route('/') 7 | def home(): 8 | return render_template('home.html', posts=posts) 9 | 10 | if __name__ == '__main__': 11 | app.run(debug=True) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flask Blog 2 | 3 | Menor e mais simples Blog do Mundo. 4 | 5 | Pequena aplicação feita como exemplo para ensinar como fazer Deploy de uma aplicação Flask. 6 | 7 | Leia o **[Tutorial](https://akiradev.netlify.app/posts/flask-heroku/)** 8 | 9 | --- 10 | 11 | ## Como utilizar a aplicação 12 | 13 | ### Crie um clone do repositório 14 | 15 | ``` 16 | git clone https://github.com/the-akira/Flask-Blog.git 17 | ``` 18 | 19 | ### Dentro do diretório principal 20 | 21 | Crie um Ambiente Virtual 22 | 23 | ``` 24 | python -m venv myvenv 25 | ``` 26 | 27 | Ative o Ambiente Virtual 28 | 29 | ``` 30 | source myvenv/bin/activate 31 | ``` 32 | 33 | Instale as dependências necessárias 34 | 35 | ``` 36 | pip install -r requirements.txt 37 | ``` 38 | 39 | Execute o arquivo `app.py` 40 | 41 | ``` 42 | python app.py 43 | ``` 44 | 45 | Navegue até a página `http://127.0.0.1:5000/` para ver a aplicação. 46 | 47 | Utilize o arquivo `posts.py` para definir os **posts** do blog 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Gabriel Felippe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Flask App 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 |
20 | 21 | {% for post in posts %} 22 |
23 |

{{ post.titulo }}

24 | 25 |

Escrito por {{ post.autor }}

26 |

{{ post.conteudo }}

27 | Ler mais 28 |
29 |

{{ post.data }}

30 |
31 |
32 |
33 | {% endfor %} 34 | 35 | 36 | -------------------------------------------------------------------------------- /static/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #9e9e9e; 3 | } 4 | 5 | .titulo { 6 | display: inline-block; 7 | margin-top: 0; 8 | margin-bottom: 5px; 9 | padding-bottom: 3px; 10 | padding-right: 5px; 11 | border-bottom: 1px solid white; 12 | border-right: 1px solid white; 13 | } 14 | 15 | img { 16 | height: 53px; 17 | width: 53px; 18 | float: right; 19 | margin: 4.3px; 20 | border-radius: 33px; 21 | border: 0.5px solid #fefefe; 22 | } 23 | 24 | img:hover { 25 | cursor: pointer; 26 | border: 0.5px solid #9e9e9e; 27 | opacity: 0.8; 28 | } 29 | 30 | .header { 31 | margin-top: 25px; 32 | display: block; 33 | margin-left: auto; 34 | margin-right: auto; 35 | width: 60%; 36 | text-align: center; 37 | } 38 | 39 | i { 40 | color: #18181f; 41 | margin-right: 10px; 42 | } 43 | 44 | i:hover { 45 | color: black; 46 | } 47 | 48 | .container { 49 | background-color: #18181f; 50 | width: 63%; 51 | display: block; 52 | margin: 25px auto 10px auto; 53 | padding: 15px; 54 | border: 1.5px dotted #fefefe; 55 | color: #e4e4f0; 56 | box-shadow: 7px 7px; 57 | } 58 | 59 | .link { 60 | color: white; 61 | background-color: black; 62 | border: 1.5px solid #fefefe; 63 | padding: 6.6px; 64 | text-decoration: none; 65 | } 66 | 67 | .link:hover { 68 | background-color: #18181f; 69 | } 70 | 71 | .data { 72 | display: flex; 73 | flex-direction: column; 74 | } 75 | 76 | .dt { 77 | display: inline-block; 78 | text-align: right; 79 | } 80 | 81 | .texto { 82 | margin-bottom: 23px; 83 | text-align: justify; 84 | } -------------------------------------------------------------------------------- /posts.py: -------------------------------------------------------------------------------- 1 | # Arquivo para a definição dos posts 2 | # Para criar um post é necessário adicionar um dicionário à lista posts com as seguintes entradas: 3 | ## 'autor': 'Nome do autor' 4 | ## 'titulo': 'Título do Post' 5 | ## 'conteudo': 'Breve descrição sobre o post' 6 | ## 'data': 'data em que foi postado' 7 | ## 'url': 'URL para o post, pode ser por exemplo um repositório git' 8 | ## 'avatar': 'imagem que representa o post' 9 | posts = [ 10 | { 11 | 'autor': 'Gabriel Felippe', 12 | 'titulo': 'Conceitos de Machine Learning', 13 | 'conteudo': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s', 14 | 'data': 'April 21, 2019', 15 | 'url': 'https://github.com/the-akira', 16 | 'avatar': 'https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/hal9000.jpg' 17 | }, 18 | { 19 | 'autor': 'Gabriel Felippe', 20 | 'titulo': 'Data Science', 21 | 'conteudo': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s', 22 | 'data': 'April 27, 2019', 23 | 'url': 'https://github.com/the-akira', 24 | 'avatar': 'https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/flower.gif' 25 | }, 26 | { 27 | 'autor': 'Gabriel Felippe', 28 | 'titulo': 'Python', 29 | 'conteudo': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s', 30 | 'data': 'April 28, 2019', 31 | 'url': 'https://github.com/the-akira', 32 | 'avatar': 'https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/lisp.png' 33 | }, 34 | { 35 | 'autor': 'Gabriel Felippe', 36 | 'titulo': 'Desenvolvendo Aplicações com Flask', 37 | 'conteudo': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s', 38 | 'data': 'May 28, 2019', 39 | 'url': 'https://github.com/the-akira', 40 | 'avatar': 'https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/mandelbrotset.jpg' 41 | }, 42 | { 43 | 'autor': 'Gabriel Felippe', 44 | 'titulo': 'Programação Básica com Python', 45 | 'conteudo': 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s', 46 | 'data': 'April 28, 2019', 47 | 'url': 'https://github.com/the-akira', 48 | 'avatar': 'https://raw.githubusercontent.com/the-akira/Flask-Blog/master/static/imagens/fractal.jpg' 49 | } 50 | ] 51 | --------------------------------------------------------------------------------