這裡記錄下乙個flask+vue的乙個示例
1.系統環境:python3.7
sqlite3資料庫,資料庫名稱:books.db
2.專案結構
",title='測試'
)"/api/books")
defbooks():
conn = sqlite3.connect("
books.db")
conn.row_factory =sqlite3.row
cur =conn.cursor()
sql = "
select * from books
"rows =cur.execute(sql).fetchall()
rows = [dict(row) for row in
rows]
return jsonify(rows)
4.index.html
doctype html5.構造資料庫語句>
<
html
lang
="en"
>
<
head
>
<
meta
charset
="utf-8"
>
<
meta
name
="viewport"
content
="width=device-width,initial-scale=1.0"
>
<
title
>flask vue
title
>
<
script
src=""
>
script
>
<
script
src=""
>
script
>
head
>
<
body
>
<
div
id>
<
h1>flask & vue.js }
h1>
<
table
border
="1"
cellpadding
=5 cellspacing
=5>
<
tr>
<
td>id
td>
<
td>標題
td>
<
td>作者
td>
<
td>定價
td>
tr>
<
tr v-for
="book in books"
>
<
td>[[book.id]]
td>
<
td>[[book.title]]
td>
<
td>[[book.author]]
td>
<
td>[[book.price]]
td>
tr>
table
>
<
script
>
var=
newvue(,
delimiters:["[[
","]]
"],mounted:
function
(), methods:,err
=>
); }}})
script
>
div>
body
>
html
>
16.示例效果.建立資料庫
sqlite3 books.db
2.建立表
create
table books(id int
primary
keynot
null,title text
notnull,author text
notnull,price real
notnull);3
.插入記錄
insert
into books values(1,'
python
','eason
',39.0
);insert
into books values(2,'
django
','eason
',99.0
);insert
into books values(3,'
flask
','eason
',129.0
);insert
into books values(4,'
vuejs
','eason
',50.0);
xml的乙個示例
function.h cstring openfile cstring cstring getcontext cstring,int,int void str2array cstring struct xmlnode function.cpp include include include incl...
NHibernate的乙個示例
一 建立poco實體 工廠表factoryentity,關聯企業表companyentiry,company id關聯t pm company表 企業表 manytoone name companyentity classtype typeof companyentity lazy laziness...
乙個PlaySound示例
using system using system.collections using system.componentmodel using system.runtime.interopservices internal class helpers dllimport winmm public s...