Service End-end
#!/usr/bin/env python # encoding:utf-8 "" "@version: v1.0 @author: Cxa @file: flask04.py @time: 2018/04/13 16:06 "" "" "" "HTTP Method" "" from Flask import flask,requestapp=flask (__name__) @app. Route ("/") def Index (): return
Client:
#!/usr/bin/env python # encoding:utf-8 "" "@version: v1.0 @author: Cxa @file: client.py @time: 2018/04/13 16:17" "" Import requestsfrom fake_useragent Import useragentheaders = { ' user-agent ': useragent (). Random, ' Accept-encoding ': ' gzip, deflate, sdch ', ' accept-language ': ' zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 ', ' Accept ': ' text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 ', ' Connection ': ' Keep-alive '}user_info={ ' Name ': ' Cxa ', ' password ': ' 123 '}r=requests.post ("Http://127.0.0.1:5000/register", Data=user_info,headers=headers) Print (R.text)
Flask Learning 4 HTTP methods