templates/account.html
<body class="container"> <h1 class="display-6 my-2">Crypt Wallet</h1> <hr> <nav aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="/">Home</a></li> <li class="breadcrumb-item"><a href="/account">アカウント情報</a></li> </ol> </nav> <div class="alert alert-primary"> <p class="my-2">秘密鍵、公開鍵、アドレスを生成しました。</p> </div> <dl class="row"> <dt class="col-sm-3">秘密鍵</dt> <dd class="col-sm-9">{{private_key}}</dd> <dt class="col-sm-3">公開鍵</dt> <dd class="col-sm-9">{{public_key}}</dd> <dt class="col-sm-3">アドレス</dt> <dd class="col-sm-9">{{address}}</dd> </dl> <br><br> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script> </body>
async fn handle_account()-> axum::response::Html<String> { let signing_key = SigningKey::random(&mut OsRng); let private_key = hex::encode(signing_key.to_bytes()); let verifying_key = signing_key.verifying_key(); let public_key = hex::encode(verifying_key.to_sec1_bytes()); let address = new_address(&verifying_key); let tera = tera::Tera::new("templates/*").unwrap(); let mut context = tera::Context::new(); context.insert("private_key", &private_key); context.insert("public_key", &public_key); context.insert("address", &address); let output = tera.render("account.html", &context); axum::response::Html(output.unwrap()) }
リファクタリングが必要だけど、やりたいことは大体できている^^