Back-end separation calculator

The Link Your Classhttps://bbs.csdn.net/forums/ssynkqtd-04
The Link of Requirement of This Assignmenthttps://bbs.csdn.net/topics/617378696
The Aim of This AssignmentBack-end separation calculator programming
MU STU ID and FZU STU ID21126046_832101204

Github project address:https://github.com/qing20030103/calculator1

1.PSP

Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning
• Estimate4040
Development
• Analysis3050
• Design Spec6060
• Design Review6070
• Coding Standard9090
• Design90100
• Coding120155
• Code Review6070
• Test20351
Reporting
• Test Repor3031
• Size Measurement2820
• Postmortem & Process Improvement Plan4050
Sum668767

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

  1. 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值