我正在编写一个简单的wsgi脚本来上传文件.使用html表单.
以下是wsgi脚本,
import os
import cgi
import cgitb; cgitb.enable()
class upfile(object):
def __init__(self):
self.script_dir = os.path.dirname(__file__)
self.errors = []
def __call__(self, environ, start_response):
f = open(os.path.join(self.script_dir, 'upload.html'))
self.output = f.read()
f.close()
self.response_content_type = 'text/html;charset=UTF-8'
fields = None
if 'POST' == environ['REQUEST_METHOD'] :
fields = cgi.FieldStorage(fp=environ['wsgi.input'],environ=environ, keep_blank_values=1)
fileitem = fields['file']
fn = os.path.basename(fileitem.filename)
open('uploads/' + fn, 'wb').write(fileitem.file.read())
self.output = self.output % {"filepath":str(fields)} # Just to see the contents
response_headers = [('Content-type', self.response_content_type),('Content-Length', str(len(self.output)))]
status = '200 OK'
start_response(status, response_headers)
return [self.output] …Run Code Online (Sandbox Code Playgroud) 我正在尝试发送特定的数据包大小(100 字节),scapy但似乎无法获取它。
我用这个来开始。
sr(IP(dst="192.168.1.1")/TCP(dport=443))
Run Code Online (Sandbox Code Playgroud)
查看文档/帮助,我无法判断是否可以用来PacketLenField指定数据包的长度。我可以使用 NMAP 和 NSE 来完成此操作,但想在 NMAP 之外执行此操作。
对这个有什么想法吗?
谢谢!
我有一个阵列
var months = ["January", "February", "March", "April", \
"May", "June", "July", "August", "September", "October", \
"November", "December"];
Run Code Online (Sandbox Code Playgroud)
我有"Nov","October","Jun","June","Sept","Sep"等字符串.重点是,字符串可以是其中一个月的子字符串.
将字符串作为数组元素的子字符串进行比较的最佳方法是什么?我如何找出当月的指数?
我在看javascript/jQuery.
我知道我可以循环遍历数组检查每个元素使用search和中断时找到.我想要更好的东西.
我在python中,有很多方法可以访问文件.
方法1:
fp = open("hello.txt", "w")
fp.write("No no no");
fp.close()
fp = open("hello.txt", "r")
print fp.read()
fp.close()
Run Code Online (Sandbox Code Playgroud)
方法2:
open("hello.txt", "w").write("hello world!")
print open("hello.txt", "r").read()
Run Code Online (Sandbox Code Playgroud)
方法3:
with open("hello.txt","w") as f:
f.write("Yes yes yes")
with open("hello.txt") as f:
print f.read()
Run Code Online (Sandbox Code Playgroud)
使用这些中的每一个都有特定的优势吗?
我知道的东西:
有什么简单的方法可以阻止用户接受html文本框中的数值吗?我遇到过HTML5的一些功能,比如type ="email"等......
现在是否有任何仅接受字符值的功能?