問(wèn)了文心一言和訊飛火星都沒(méi)法給出可正確運(yùn)行的示例代碼,還得我自己改一改
import http.server
import socketserver
import os
class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
static_files_dir = './static/'
def do_GET(self):
# 拼接請(qǐng)求路徑和靜態(tài)文件目錄
full_path = self.static_files_dir + self.path
# 檢查路徑是否是一個(gè)存在的目錄
if os.path.isdir(full_path):
# 如果是熟嫩,重定向到 index.html
self.path =self.static_files_dir + '/index.html'
else:
self.path = full_path
return super().do_GET()
# 創(chuàng)建服務(wù)器
PORT = 8000
Handler = MyHttpRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
print("serving at port", PORT)
httpd.serve_forever()
接著我又讓AI給我寫(xiě)了一個(gè)ftp服務(wù)器,這次代碼直接可用
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler, ThrottledDTPHandler
from pyftpdlib.servers import FTPServer
# 設(shè)置FTP服務(wù)器目錄
directory = './static'
# 創(chuàng)建FTP用戶授權(quán)管理器
authorizer = DummyAuthorizer()
authorizer.add_user('user', '12345', directory, perm='elradfmwMT')
# 創(chuàng)建FTP處理器
handler = FTPHandler
handler.authorizer = authorizer
handler.dtp_handler = ThrottledDTPHandler
# 創(chuàng)建FTP服務(wù)器并綁定到指定地址和端口
server = FTPServer(('0.0.0.0', 11134), handler)
# 啟動(dòng)FTP服務(wù)器
server.serve_forever()
一些思考:現(xiàn)在大模型真的可以寫(xiě)代碼,只是代碼質(zhì)量還不夠好,我有一個(gè)猜想,如果給計(jì)算機(jī)病毒掛上一個(gè)大模型,讓計(jì)算機(jī)病毒利用宿主的計(jì)算資源不斷的修改自身的代碼,是不是有可能編寫(xiě)出更加復(fù)雜的病毒,最終攻克所有不能及時(shí)變動(dòng)的防線