码迷,mamicode.com
首页 > Web开发 > 详细

云计算学习路线教程大纲课件:关于HTTP Server

时间:2019-10-22 10:31:37      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:结合   key   eth   port   star   path   handler   gen   教程   

云计算学习路线教程大纲课件:关于HTTP Server:

========================================================

静态元素: .html .img js css swf mp4

动态元素: .php .jsp .cgi .asp php SQL

Web Server:

Nginx(Tengine)、Apache、IIS

Web 中间件:

php: PHP-fpm、HHVM

jsp: Tomcat、JBOSS、Resin、IBM WebSphere

常见组合方式:

LNMP (Linux + Nginx + MySQL + PHP) //php-fpm进程

LAMP (Linux + Apache + MySQL + PHP) //php作为Apache的模块

Nginx + Tomcat //取代Apache与Tomcat结合

========================================================

server:

#coding=utf-8

from BaseHTTPServer import BaseHTTPRequestHandler

import cgi

class PostHandler(BaseHTTPRequestHandler):

def do_POST(self):

form = cgi.FieldStorage(

fp=self.rfile,

headers=self.headers,

environ={‘REQUEST_METHOD‘:‘POST‘,

‘CONTENT_TYPE‘:self.headers[‘Content-Type‘],

}

self.send_response(200)

self.end_headers()

self.wfile.write(‘Client: %sn ‘ % str(self.client_address) )

self.wfile.write(‘User-agent: %sn‘ % str(self.headers[‘user-agent‘]))

self.wfile.write(‘Path: %sn‘%self.path)

self.wfile.write(‘Form data:n‘)

for field in form.keys():

field_item = form[field]

filename = field_item.filename

filevalue = field_item.value

filesize = len(filevalue)#文件大小(字节)

#print len(filevalue)

#print (filename)

with open(filename.decode(‘utf-8‘),‘wb‘) as f:

f.write(filevalue)

return

def StartServer():

from BaseHTTPServer import HTTPServer

sever = HTTPServer(("",8080),PostHandler)

sever.serve_forever()

if name==‘main‘:

StartServer()

client:

#coding=utf-8

import requests

url = "http://172.16.1.101:8080"

path = "/home/ly/ly.exe"

print path

files = {‘file‘: open(path, ‘rb‘)}

r = requests.post(url, files=files)

print (r.url)

print (r.text)

云计算学习路线教程大纲课件:关于HTTP Server

标签:结合   key   eth   port   star   path   handler   gen   教程   

原文地址:https://blog.51cto.com/14489558/2444212

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!