92 lines
1.6 KiB
Python
92 lines
1.6 KiB
Python
import flask
|
|
import pbc_client
|
|
import dataclasses
|
|
import requests_cache
|
|
|
|
|
|
HTML_INDEX = """
|
|
|
|
|
|
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<style>
|
|
|
|
html {
|
|
background-color: #222;
|
|
color: white;
|
|
font-family: sans;
|
|
}
|
|
|
|
body {
|
|
width: 80%;
|
|
margin: auto;
|
|
}
|
|
|
|
.notamon-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(10, 1fr);
|
|
justify-items: center;
|
|
text-align: center;
|
|
gap: 4em 1em;
|
|
}
|
|
|
|
.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',
|
|
)
|
|
|
|
ADDRESS_NFTS = ''
|
|
ADDRESS_ASSETS = ''
|
|
|
|
SESSION = requests_cache.CachedSession()
|
|
|
|
def determine_notamons():
|
|
client = pbc_client.PbcClient(SESSION, pbc_client.HOSTNAME_TESTNET)
|
|
asset_contract_state = client.get_contract_state(ADDRESS_ASSETS)
|
|
|
|
return [TEST_NOTAMON for i in range(100)]
|
|
|
|
@app.route("/")
|
|
def hello_world():
|
|
return flask.render_template_string(HTML_INDEX, notamons = determine_notamons())
|
|
|