Go to the Home Page
Compare With HTMLAndCpp
web4.py
# -*- coding: utf-8 -*-
from bottle import route,run,template,request
@route("/")
def toppage():
return template("toppage")
@route("/result",method="get")
def result():
usrname_client=request.query.getunicode("inputname")
return template("result",usrname_server=usrname_client)
run(host="localhost",port=8080,debug=True)
toppage.html
<!DOCTYPE html>
<html lang="ja">
<head><meta charset="utf-8"><title>web3_2</title></head>
<body>
<h1>Top Page</h1>
<form action="/result" method="get">
<input type="text" name="inputname">
<input type="submit" value="sign up">
</form>
</body>
</html>
result.html
<!DOCTYPE html>
<html lang="ja">
<head><meta charset="utf-8"><title>welcome</title></head>
<body>
<h1>show user page</h1>
<p>{{usrname_server}}-----welcome!</p>
<button type="button" onclick="location.href='/'">prepage</button>
</body>
</html>
.cpp
class TextField {
public:
string text;
void setText(string newText) { text = newText; }
string getText() { return text; }
};
TextField inputname;
inputname.setText("Hello");
.cpp
class TextField {
public:
string type = "text";
};
.cpp
class TextField {
public:
string name = "inputname";
};