切换到宽版
北斗六星!·百事通·查看新帖·设为首页·手机版

北斗六星网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
北斗六星网 红袖家园 红袖杂谈 google AI Bard 使用体验
查看: 427|回复: 2
打印 上一主题 下一主题

google AI Bard 使用体验 [复制链接]

跳转到指定楼层
主楼
发表于 2023-7-17 13:25 |只看该作者 |倒序浏览 |
搜索本主题
提示: 作者被禁止或删除 仅保留发帖内容
本帖最后由 屠龙斩首 于 2023-7-17 13:28 编辑

阳康,首阳,无事可做,今儿早上用了用google的AI,Bard。好像不错哎,还不用象openAI那边小气吧啦,非得用国外手机号注册。Bard你直接用,随便用。
让Bard写了一段代码,用户前端网页输入项目,任务,工时,python后台接受输入,并存储入数据库。看代码基本直接可用,前端还给用了bootstrap。这d对实际工作确实应该会增加效率不少哟。还没时间想着怎么调教好咱们的Bard老兄,咳咳,说到底是自己懒。


以下贴代码,简单肯定是超级简单了点,没时间调教B老兄嘛。

html_bootstrap-----------------------------------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Project Time Tracking</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>
<body>
    <h1 class="text-center">Project Time Tracking</h1>
    <form action="/submit" method="post" class="container">
        <div class="mb-3">
            <label for="employee_name" class="form-label">Employee Name</label>
            <input type="text" name="employee_name" id="employee_name" class="form-control form-control-sm" placeholder="Employee Name" style="width: 400px;">
        </div>
        <div class="mb-3">
            <label for="date" class="form-label">Date</label>
            <input type="date" name="date" id="date" class="form-control form-control-sm" placeholder="Date" style="width: 400px;">
        </div>
        <div class="mb-3">
            <label for="project" class="form-label">Project</label>
            <input type="text" name="project" id="project" class="form-control form-control-sm" placeholder="Project" style="width: 400px;">
        </div>
        <div class="mb-3">
            <label for="task" class="form-label">Task</label>
            <input type="text" name="task" id="task" class="form-control form-control-sm" placeholder="Task" style="width: 400px;">
        </div>
        <div class="mb-3">
            <label for="hours" class="form-label">Hours</label>
            <input type="number" name="hours" id="hours" class="form-control form-control-sm" placeholder="Hours" step="0.01" style="width: 400px;">
        </div>
        <input type="submit" value="Submit" class="btn btn-primary">
    </form>
</body>
</html>




python_flask---------------------------------------------------------------------------------------------------------------------------------------------------------from flask import Flask, render_template, request


# 创建 Flask 应用程序
app = Flask(__name__)


# 定义路由
@app.route("/")
def index():
    return render_template("index.html")


@app.route("/submit", methods=["POST"])
def submit():
    # 获取表单数据
    employee_name = request.form["employee_name"]
    date = request.form["date"]
    project = request.form["project"]
    task = request.form["task"]
    hours = request.form["hours"]


    # 连接数据库
    connection = mysql.connector.connect(
        host='localhost',
        user='root',
        password='password',
        database='mydatabase'
    )


    # 创建游标对象
    cursor = connection.cursor()


    # 执行SQL语句
    cursor.execute('INSERT INTO time_logs (employee_name, date, project, task,


hours) VALUES (%s, %s, %s, %s, %s)', (employee_name, date, project, task, hours))


    # 提交事务
    connection.commit()


    # 关闭连接
    connection.close()


    # 重定向到主页
    return redirect('/')


if __name__ == "__main__":
    app.run(debug=True)























分享到: QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享分享0 收藏收藏0 顶0 踩0

沙发
发表于 2023-7-17 13:53 来自手机 |只看该作者
看不懂……

使用道具 举报

板凳
发表于 2023-7-17 23:45 |只看该作者

较为简单的数据库编程。

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

北斗六星文学网所有文字仅代表作者个人言论,本站不对其内容承负任何责任。

Copyright ©2011 bdlxbbs.cn All Right Reserved.  Powered by Discuz! 

本站信息均由会员发表,不代表本网站立场,如侵犯了您的权利请发帖投诉   

平平安安
TOP
返回顶部