├── .gitignore ├── requirements.txt ├── README.md ├── app.py ├── LICENSE ├── templates └── home.html └── static └── style.css /.gitignore: -------------------------------------------------------------------------------- 1 | .myvenv 2 | myvenv/ 3 | __pycache__/ 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | certifi==2019.11.28 2 | chardet==3.0.4 3 | Click==7.0 4 | Flask==1.1.1 5 | flask-paginate==0.5.5 6 | idna==2.8 7 | itsdangerous==1.1.0 8 | Jinja2==2.11.3 9 | MarkupSafe==1.1.1 10 | requests==2.22.0 11 | urllib3==1.26.5 12 | Werkzeug==0.16.0 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flask Programming Languages App 2 | 3 | Small experimental Flask App about Programming Languages 4 | 5 | ## Installation 6 | 7 | ### Clone the Repository 8 | 9 | ``` 10 | git clone https://github.com/the-akira/Flask-Programming-Languages-App.git 11 | ``` 12 | 13 | ### Inside the Main Directory 14 | 15 | Create a Virtual Environment 16 | 17 | ``` 18 | python -m venv myvenv 19 | ``` 20 | 21 | Activate the Virtual Environment 22 | 23 | ``` 24 | source myvenv/bin/activate 25 | ``` 26 | 27 | Install Requirements 28 | 29 | ``` 30 | pip install -r requirements.txt 31 | ``` 32 | 33 | Run the Application 34 | 35 | ``` 36 | python app.py 37 | ``` 38 | 39 | In order to change the default number of posts per page you have to change the **per_page** variable in `flask_paginate.__init__.py` file 40 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template 2 | from flask_paginate import Pagination, get_page_args 3 | import requests 4 | import csv 5 | 6 | # Request csv data 7 | data = requests.get('https://gist.githubusercontent.com/the-akira/6b1eeb40ad6a0790460000eb0ae40073/raw/27ddb6bb25acb1b455987c882554f7d54a16c7ac/programming_languages.csv') 8 | 9 | app = Flask(__name__) 10 | 11 | # Convert csv object into Python List 12 | languages = list(csv.reader(data.text.strip().split('\n'))) 13 | 14 | def get_lang(offset=0, per_page=10): 15 | return languages[offset: offset + per_page] 16 | 17 | @app.route('/') 18 | def index(): 19 | page, per_page, offset = get_page_args(page_parameter='page', per_page_parameter='per_page') 20 | total = len(languages) 21 | pag_langs = get_lang(offset=offset, per_page=per_page) 22 | pagination = Pagination(page=page, per_page=per_page, total=total) 23 | return render_template('home.html',languages=pag_langs,page=page,per_page=per_page,pagination=pagination) 24 | 25 | if __name__ == '__main__': 26 | app.run(debug=True) -------------------------------------------------------------------------------- /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 | Flask Programming Languages 7 | 8 | 9 | 10 | 11 |

Flask Programming Languages App

12 |

13 | A programming language is a vocabulary and set of grammatical rules for instructing a computer or computing device to perform specific tasks. The term programming language usually refers to high-level languages, such as BASIC, C, C++, COBOL, Java, FORTRAN, Ada, and Pascal. 14 | 15 | Each programming language has a unique set of keywords (words that it understands) and a special syntax for organizing program instructions. 16 |

17 |
18 | 19 | 20 | 21 | 22 |
23 |
24 |
25 |
26 | {% for language in languages %} 27 |
28 |

{{ language[0] }}

29 | Read more 30 |
31 | {% endfor %} 32 |
33 |
34 | {{ pagination.links }} 35 | 36 | -------------------------------------------------------------------------------- /static/style.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Aldrich&display=swap'); 2 | 3 | body { 4 | background-color: #374f66; 5 | } 6 | 7 | .pagination { 8 | margin-left: auto; 9 | margin-right: auto; 10 | margin-bottom: 30px; 11 | width: 100%; 12 | text-align: center; 13 | } 14 | 15 | ul { 16 | padding: 10px !important; 17 | margin: 10px !important; 18 | display: flex; 19 | justify-content: center; 20 | } 21 | 22 | li { 23 | list-style: none; 24 | } 25 | 26 | .pagination>ul>li>a { 27 | text-decoration: none; 28 | color: black; 29 | padding: 10px; 30 | border: 1.3px solid black; 31 | display: inline; 32 | background-color: #b1c2de; 33 | box-shadow: 3px 3px 3px rgba(0, 0, 0, .5); 34 | } 35 | 36 | .pagination>ul>li.active { 37 | opacity: 0.6; 38 | } 39 | 40 | .link { 41 | color: black; 42 | text-align: center; 43 | display: block; 44 | margin-top: 30px; 45 | border: 1px solid black; 46 | background-color: #374f66; 47 | color: #b1c2de; 48 | padding: 6px; 49 | border-radius: 5px; 50 | transition: background-color 2.5s; 51 | } 52 | 53 | .title { 54 | text-align: center; 55 | margin-top: 40px; 56 | margin-bottom: 25px; 57 | color: white; 58 | font-family: 'Aldrich', sans-serif; 59 | font-size: 2.7rem; 60 | } 61 | 62 | .description { 63 | margin: 0 auto; 64 | margin-bottom: 24px; 65 | width: 80%; 66 | text-align: justify; 67 | color: #ffffff; 68 | font-size: 1.03rem; 69 | } 70 | 71 | hr { 72 | color: #b1c2de; 73 | } 74 | 75 | .link:hover { 76 | background-color: black; 77 | text-decoration: none; 78 | } 79 | 80 | .container { 81 | margin: 0 auto; 82 | max-width: 1400px; 83 | } 84 | 85 | .linguagens { 86 | list-style-type: none; 87 | margin-left: 0; 88 | margin-top: 0; 89 | display: grid; 90 | grid-template-columns: repeat(auto-fill, minmax(256px, 1fr)); 91 | grid-template-rows: auto; 92 | justify-content: space-evenly; 93 | padding: 15px; 94 | grid-column-gap: 22px; 95 | overflow-x: hidden; 96 | } 97 | 98 | .linguagem-container { 99 | padding: 60px; 100 | background-color: #b1c2de; 101 | margin-bottom: 18px; 102 | color: black; 103 | border: 2px solid black; 104 | border-radius: 7px; 105 | box-shadow: 5px 5px 5px rgba(0, 0, 0, .5); 106 | } 107 | 108 | .linguagem-nome { 109 | text-align: center; 110 | font-family: 'Aldrich', sans-serif; 111 | font-size: 1.5rem; 112 | } 113 | 114 | .header { 115 | margin-bottom: 30px; 116 | display: block; 117 | margin-left: auto; 118 | margin-right: auto; 119 | width: 60%; 120 | text-align: center; 121 | } 122 | 123 | i { 124 | margin-right: 7px; 125 | color: #b1c2de; 126 | } --------------------------------------------------------------------------------