python.py
通價值
from flask import Flask,render_template
app=Flask(__name__)
@app.route("login")
def home():
return render_template('login.html',name='login')
@app.route("/")
def calculation():
return render_template('function.html')
if __name__=='__main__':
app.run()
function.html
<html>
<head></head>
<body>
<h3>Simple Calculator</h3>
<br/>
<style>
#calc{width:300px;height:250px;}
#btn{width:100%;height:40px;font-size:20px;}
</style>
<form Name="calc">
<table id="calc" border=2>
<tr>
<td colspan=5><input id="btn" name="display" onkeypress="return event.charCode >= 48 && event.charCode <= 57" type="text"></td>
<td style="display:none"><input name="M" type="number"></td>
</tr>
<tr>
<td><input id="btn" type=button value="0" OnClick="calc.display.value+='0'"></td>
<td><input id="btn" type=button value="1" OnClick="calc.display.value+='1'"></td>
<td><input id="btn" type=button value="2" OnClick="calc.display.value+='2'"></td>
<td><input id="btn" type=button value="+" OnClick="calc.display.value+='+'"></td>
</tr>
<tr>
<td><input id="btn" type=button value="3" OnClick="calc.display.value+='3'"></td>
<td><input id="btn" type=button value="4" OnClick="calc.display.value+='4'"></td>
<td><input id="btn" type=button value="5" OnClick="calc.display.value+='5'"></td>
<td><input id="btn" type=button value="-" OnClick="calc.display.value+='-'"></td>
</tr>
<tr>
<td><input id="btn" type=button value="6" OnClick="calc.display.value+='6'"></td>
<td><input id="btn" type=button value="7" OnClick="calc.display.value+='7'"></td>
<td><input id="btn" type=button value="8" OnClick="calc.display.value+='8'"></td>
<td><input id="btn" type=button value="x" OnClick="calc.display.value+='*'"></td>
</tr>
<tr>
<td><input id="btn" type=button value="9" OnClick="calc.display.value+='9'"></td>
</td>
<td><input id="btn" type=button value="=" OnClick="calc.display.value=eval(calc.display.value)"></td>
<td><input id="btn" type=button value="/" OnClick="calc.display.value+='/'"></td>
</tr>
</table>
</form>
</body>
</html>
login.html
<html>
<head><title>welcome</title></head>
<form action="/action_page.php">
<div class="container">
<label><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<link rel="next" href="function.html">
</div>
</form>
</html>
我創建了這條巨蟒文件,我已經創建了兩個HTML文件。我不知道如何從蟒蛇驗證到HTML文件 使用燒瓶框架
- 在那個地方創建一個主頁的名稱創建下面的示例,並添加像計算器和形式
- 兩個按鈕同時點擊計算器按鈕頁面必須重定向該頁面中的另一頁面所有計算器功能必須呈現如加,減,乘除
- 同時單擊表單按鈕頁面必須重定向另一頁面,創建兩個文本框,如用戶名,點擊提交按鈕時提交的密碼和按鈕等提示輸入的用戶名和密碼必須顯示在屏幕上e網頁底部。
這是我的任務,通過我必須編寫上面的代碼,但我不能將html文件呈現給python。
https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world –
感謝您的寶貴意見 – venkatvnb