├── .gitignore ├── static ├── imagens │ ├── book.png │ ├── wall.png │ ├── avatar.png │ ├── portal.gif │ └── texture.jpg ├── script.js └── style.css ├── requirements.txt ├── README.md ├── app.py ├── LICENSE └── templates └── home.html /.gitignore: -------------------------------------------------------------------------------- 1 | .myvenv 2 | myvenv/ 3 | __pycache__/ 4 | -------------------------------------------------------------------------------- /static/imagens/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Dungeons-and-Dragons/master/static/imagens/book.png -------------------------------------------------------------------------------- /static/imagens/wall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Dungeons-and-Dragons/master/static/imagens/wall.png -------------------------------------------------------------------------------- /static/imagens/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Dungeons-and-Dragons/master/static/imagens/avatar.png -------------------------------------------------------------------------------- /static/imagens/portal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Dungeons-and-Dragons/master/static/imagens/portal.gif -------------------------------------------------------------------------------- /static/imagens/texture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-akira/Flask-Dungeons-and-Dragons/master/static/imagens/texture.jpg -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /static/script.js: -------------------------------------------------------------------------------- 1 | var mybutton = document.getElementById("portal"); 2 | window.onscroll = function() {scrollFunction()}; 3 | 4 | function scrollFunction() { 5 | if (document.body.scrollTop > 60 || document.documentElement.scrollTop > 60) { 6 | mybutton.style.display = "block"; 7 | } else { 8 | mybutton.style.display = "none"; 9 | } 10 | } 11 | function topFunction() { 12 | document.body.scrollTop = 0; 13 | document.documentElement.scrollTop = 0; 14 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
8 | A simple Dungeons & Dragons Flask App 9 |
10 | 11 | ## Installation 12 | 13 | ### Clone the Repository 14 | 15 | ``` 16 | git clone https://github.com/the-akira/Flask-Dungeons-and-Dragons.git 17 | ``` 18 | 19 | ### Inside the Main Directory 20 | 21 | Create a Virtual Environment 22 | 23 | ``` 24 | python -m venv myvenv 25 | ``` 26 | 27 | Activate the Virtual Environment 28 | 29 | ``` 30 | source myvenv/bin/activate 31 | ``` 32 | 33 | Install Requirements 34 | 35 | ``` 36 | pip install -r requirements.txt 37 | ``` 38 | 39 | Run the Application 40 | 41 | ``` 42 | python app.py 43 | ``` 44 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template 2 | from flask_paginate import Pagination, get_page_args 3 | import requests 4 | import json 5 | 6 | # Request JSON data 7 | data = requests.get('https://gist.githubusercontent.com/the-akira/65dc489c66fc035ceb8dfc65c1c3da0d/raw/d4df8804c25a662efc42936db60cfbc0a5b19db8/srd_5e_monsters.json').text 8 | 9 | app = Flask(__name__) 10 | 11 | # Load raw JSON into Python Dictionary 12 | monsters = json.loads(data) 13 | 14 | def get_monster(offset=0, per_page=10): 15 | return monsters[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(monsters) 21 | pag_monsters = get_monster(offset=offset, per_page=per_page) 22 | pagination = Pagination(page=page, per_page=per_page, total=total) 23 | return render_template('home.html',monsters=pag_monsters,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 |15 | Dungeons & Dragons (commonly abbreviated as D&D or DnD) is a fantasy tabletop role-playing game (RPG) originally designed by Gary Gygax and Dave Arneson. It was first published in 1974 by Tactical Studies Rules, Inc. (TSR). The game has been published by Wizards of the Coast (now a subsidiary of Hasbro) since 1997. It was derived from miniature wargames, with a variation of the 1971 game Chainmail serving as the initial rule system. D&D's publication is commonly recognized as the beginning of modern role-playing games and the role-playing game industry. 16 |
17 | 22 |{{ monster['name'] }}
28 |{{ monster['meta'] }}
31 |{{ monster['Armor Class'] }}
32 |{{ monster['Hit Points'] }}
33 |{{ monster['Speed'] }}
34 || Attribute | 37 |Points | 38 |
|---|---|
STR |
41 | {{ monster['STR'] }} |
42 |
DEX |
45 | {{ monster['DEX'] }} |
46 |
CON |
49 | {{ monster['CON'] }} |
50 |
INT |
53 | {{ monster['INT'] }} |
54 |
WIS |
57 | {{ monster['WIS'] }} |
58 |
CHA |
61 | {{ monster['CHA'] }} |
62 |
{{ monster['Skills'] }}
65 |{{ monster['Languages']}}
66 |{{ monster['Traits']| safe }}
67 |{{ monster['Actions']| safe}}
68 |{{ monster['Legendary Actions']| safe}}
69 |