Testing frontend
This commit is contained in:
parent
14bf6a72cd
commit
a1c0771298
75
python/notamon_viewer/app.py
Normal file
75
python/notamon_viewer/app.py
Normal file
|
@ -0,0 +1,75 @@
|
|||
import flask
|
||||
import pbc_client
|
||||
import dataclasses
|
||||
|
||||
|
||||
HTML_INDEX = """
|
||||
|
||||
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
|
||||
body {
|
||||
width: 80%;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.notamon-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(10, 1fr);
|
||||
justify-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.notamon h2, h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
<title>Hello from Flask</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="notamon-grid">
|
||||
|
||||
{% for notamon in notamons %}
|
||||
<div class="notamon">
|
||||
<img src="{{ notamon.image_src }}" style="{{ notamon.effect_css }}">
|
||||
<h2>{{ notamon.nickname }}</h2>
|
||||
<h3>{{ notamon.species_name }}</h3>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Notamon:
|
||||
image_src: str
|
||||
effect_css: str
|
||||
nickname: str
|
||||
species_name: str
|
||||
|
||||
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
TEST_NOTAMON = Notamon(
|
||||
image_src = 'https://img.pokemondb.net/sprites/ruby-sapphire/normal/mudkip.png',
|
||||
effect_css = '',
|
||||
nickname = 'Dude',
|
||||
species_name = 'Mudkip',
|
||||
)
|
||||
|
||||
@app.route("/")
|
||||
def hello_world():
|
||||
|
||||
notamons = [TEST_NOTAMON for i in range(100)]
|
||||
|
||||
return flask.render_template_string(HTML_INDEX, notamons = notamons)
|
||||
|
Loading…
Reference in New Issue
Block a user