├── .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 |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 | 23 |{{ language[0] }}
29 | Read more 30 |