The Link Your Class | https://bbs.csdn.net/forums/ssynkqtd-04 |
---|---|
The Link of Requirement of This Assignment | https://bbs.csdn.net/topics/617378696 |
The Aim of This Assignment | Back-end separation calculator programming |
MU STU ID and FZU STU ID | 21126046_832101204 |
Github project address:https://github.com/qing20030103/calculator1
1.PSP
Personal Software Process Stages | Estimated Time(minutes) | Actual Time(minutes) |
---|---|---|
Planning | ||
• Estimate | 40 | 40 |
Development | ||
• Analysis | 30 | 50 |
• Design Spec | 60 | 60 |
• Design Review | 60 | 70 |
• Coding Standard | 90 | 90 |
• Design | 90 | 100 |
• Coding | 120 | 155 |
• Code Review | 60 | 70 |
• Test | 20 | 351 |
Reporting | ||
• Test Repor | 30 | 31 |
• Size Measurement | 28 | 20 |
• Postmortem & Process Improvement Plan | 40 | 50 |
Sum | 668 | 767 |
2.Solution idea description
1.The front-end uses the previous page design .
2.back-end interacts with the front-end database, using Python’s flask framework and pymysql to achieve these two functions.
3. The database is implemented by mysql.Tools used:Navicat
3.Design and implementation process
- Front-end
The front-end requests the back-end interface:
function conn1() {
var data1 = $('#expression').val();
$.ajax({
url: '/',
method: 'POST',
contentType: 'calcultor/json',
data: JSON.stringify({ expression: expression })
success: function (response) {
$('#expression').val(response.result)
}
2.Back-end
The backend is done using the flask and pymysql modules
Importing the flask and pymysql modules
@app.route("/",methods=["GET","POST"])
def test():
if request.method=="GET":
return render_template("12.html")
u1 = request.form.get("Screen")
conn = pymysql.connect(host='localhost', user='root', password='123456', charset='utf8', db='12')
# 创建游标
cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
# 插入
sql = "insert into user1(Screen)values(%s)"
cursor.execute(sql, [u1])
conn.commit()
cursor.close()
conn.close()
return "true"
Connect to the mysql database code
@app.route("/show/user")
def show():
conn = pymysql.connect(host='localhost', user='root', password='123456', charset='utf8', db='12')
# 创建游标
cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
# 查询
sql="select*from user1"
cursor.execute(sql)
data=cursor.fetchall()
cursor.close()
conn.close()
print(data)
return render_template("showuser.html",data_list=data)
Database returns data
3.Database Creation
Navicat is used to connect to mysql database, and tools are used to manage the database.
The returned characters are stored in a table
4.Front-end interaction
function conn1() {
var data1 = $('#expression').val();
$.ajax({
url: '/',
method: 'POST',
contentType: 'calcultor/json',
data: JSON.stringify({ expression: expression })
success: function (response) {
$('#expression').val(response.result)
}
ajax request is used to send when the front and back end interact, and when the equal is pressed, the text box is sent to the back end, and the back end processes the data after receiving
4.Demonstration of results
Scientific Calculator Functions
Click the ans button to return to the historical data
5.Summary
In this task, mathematical logic is used to realize the function of the calculator, and the back-end uses Python’s Flask framework to receive the request sent by the front-end and execute the corresponding calculation logic. Familiar with the front-end page design, through learning and practice, master their basic usage and common functions. Master the technology of front and back end interaction, understand the development mode of front and back end separation.