《深度學習與圖像識別》課件人工智能算法應用_第1頁
《深度學習與圖像識別》課件人工智能算法應用_第2頁
《深度學習與圖像識別》課件人工智能算法應用_第3頁
《深度學習與圖像識別》課件人工智能算法應用_第4頁
《深度學習與圖像識別》課件人工智能算法應用_第5頁
已閱讀5頁,還剩16頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

Web框架web網(wǎng)站發(fā)展至今,特別是服務器端,涉及到的知識、內(nèi)容,非常廣泛。這對程序員的要求會越來越高。如果采用成熟,穩(wěn)健的框架,那么一些基礎(chǔ)的工作,比如,安全性,數(shù)據(jù)流控制等都可以讓框架來處理,那么程序開發(fā)人員可以把精力放在具體的業(yè)務邏輯上面。使用框架的優(yōu)點:穩(wěn)定性和可擴展性強可以降低開發(fā)難度,提高開發(fā)效率。為了更好的展示人工智能算法,因此可以采用pythonweb框架。在Python中常用的Web框架有:Flask、Django、Tornado安裝Flask-i/simple

pipinstallflaskpipinstallflask_migratepipinstallflask_scriptpipinstallpymysqlHelloWorldfromflaskimportFlask#導入Flask模塊

app=Flask(__name__)#創(chuàng)建應用實例

@app.route('/')#使用route裝飾器創(chuàng)建一個路由

defhello():#視圖函數(shù),訪問此路由時執(zhí)行的函數(shù)

return'HelloWorld'#視圖函數(shù)的返回值,稱之為‘響應’

if__name__=='__main__':#判斷是否運行此文件,還是被當做模塊導入

app.run(debug=True)#開始運行flask應用程序,debug啟動app的調(diào)試模式

打開瀏覽器訪問http://localhost:5000,可以看到我們的helloworld頁面已經(jīng)可以正常工作了。html代碼輸出打開瀏覽器,輸入http://localhost:5000/hellofromflaskimportFlask#導入Flask模塊

app=Flask(__name__)#創(chuàng)建應用實例

@app.route('/hello')#添加路由:hello

defdo_hello():

return'<h1>Hello,stranger!</h1>'

if__name__=='__main__':#判斷是否運行此文件,還是被當做模塊導入

app.run(debug=True)#開始運行flask應用程序,debug啟動app的調(diào)試模式html文件渲染fromflaskimportFlask#導入Flask模塊

app=Flask(__name__)#創(chuàng)建應用實例

fromflaskimportrender_template

@app.route('/')

defindex():

return'Helloindex'

@app.route('/hello')#添加路由:hello

defdo_hello():

returnrender_template('hello.html')

if__name__=='__main__':#判斷是否運行此文件,還是被當做模塊導入

app.run(debug=True)#開始運行flask應用程序,debug啟動app的調(diào)試模式代碼路徑:/3flask/hello_wordhtml變量傳遞fromflaskimportFlask#導入Flask模塊

app=Flask(__name__)#創(chuàng)建應用實例

fromflaskimportrender_template

@app.route('/hello')

@app.route('/hello/<name>')

defhello(name=None):

returnrender_template('hello_name.html',name=name)

if__name__=='__main__':#判斷是否運行此文件,還是被當做模塊導入

app.run(debug=True)#開始運行flask應用程序,debug啟動app的調(diào)試模式代碼路徑:/3flask/html重定向訪問:http://localhost:5000/redirfromflaskimportFlask#導入Flask模塊

fromflaskimportredirect

app=Flask(__name__)#創(chuàng)建應用實例

@app.route('/redir')

defredir():

returnredirect('/')

if__name__=='__main__':#判斷是否運行此文件,還是被當做模塊導入

app.run(debug=True)#開始運行flask應用程序,debug啟動app的調(diào)試模式

代碼路徑:/3flask/redirect表格<!DOCTYPEhtml>

<htmllang="en">

<head>

<metacharset="UTF-8">

<title>廣東科學技術(shù)職業(yè)學院</title>

</head>

<body>

<tableborder="1">

<tr>

<th>姓名</th>

<th>年齡</th>

</tr>

<tr>

<td>{{}}</td>

<td>{{data.age}}</td>

</tr>

</table>

</body>

</html>@app.route('/')

defdemo():

#user=User.query.first()

name="hujianhua"

age="99"

data={

"name":name,

"age":age

}

returnrender_template("index.html",data=data)表格渲染代碼路徑:/3flask/表格與數(shù)據(jù)庫/table_test.py表單<!DOCTYPEhtml>

<htmllang="en">

<head>

<metacharset="UTF-8">

<title>廣東科學技術(shù)職業(yè)學院</title>

</head>

<body>

<formmethod="post">

<label>姓名:</label><inputtype="text"name="username"placeholder="請輸入姓名"><br/>

<label>年紀:</label><inputtype="password"name="userage"placeholder="請輸入年紀"><br/>

<inputtype="submit"value="提交">

</form>

</body>

</html>表單渲染@app.route('/login',methods=["GET","POST"])

deflogin():

ifrequest.method=="POST":

username=request.form.get("username")

userage=request.form.get("userage")

print(username)

print(userage)

returnrender_template("login.html")后端向前端傳數(shù)據(jù)通過render_template(“index.html”,data=data)可以向html傳遞數(shù)據(jù)。傳單個數(shù)據(jù)returnrender_template(‘需要傳參網(wǎng)址’,xx=u‘xx’);前端接收:{{xx}}傳多個數(shù)據(jù)(見表格渲染實例)先把數(shù)據(jù)寫進字典,字典整體傳returnrender_template(‘需要傳參網(wǎng)址’,**字典名’);前端接收:{{字典名.變量名}}@app.route('/')

defdemo():

#user=User.query.first()

name="hujianhua"

age="99"

data={

"name":name,

"age":age

}

returnrender_template("index.html",data=data)表格渲染后端得到前端數(shù)據(jù)如果前端提交的方法為POST:后端接收時要寫methods=[‘GET’,‘POST’]xx=request.form.get(xx);xx=request.form[’‘xx’]如果是GETxx=request.args.get(xx)通過表單,網(wǎng)頁訪問,或者ajax等請求。網(wǎng)址傳參::5000/get_test?name=gditKey=nameValue=gdit前程向端傳遞數(shù)據(jù)后端處理數(shù)據(jù)fromflaskimportrequest表單前端<!DOCTYPEhtml>

<htmllang="en">

<head>

<metacharset="UTF-8">

<title>Xiaotaotao</title>

</head>

<body>

<formmethod="post">

<label>姓名:</label><inputtype="text"name="username"placeholder="請輸入姓名"><br/>

<label>年紀:</label><inputtype="password"name="userage"placeholder="請輸入年紀"><br/>

<inputtype="submit"value="提交">

</form>

</body>

</html>表單后端@app.route('/login',methods=["GET","POST"])

deflogin():

ifrequest.method=="POST":

username=request.form.get("username")

userage=request.form.get("userage")

print(username)

print(userage)

returnrender_template("login.html")pipinstalldlib==19.7.0pipinstallface_recognitionpipinstallPillow相關(guān)軟件安裝由于默認使用國外源進行下載安裝,導致下載速度非常慢,因此可以使用國內(nèi)源進行來加速安裝,在相應安裝命令行后加-i/simple,例如安裝numpy,使用加速國內(nèi)源進行安裝的命令為:pipinstallnumpy-i/simple

人工智能算法應用框架web前端html內(nèi)容css樣式與布局javascript微信小程序后端djangoflask前端項目實戰(zhàn)通過下載mnis

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論