+ 1
Pls tell me why this cods it only display "file list" when I open the link on browser
1 Respuesta
+ 1
I finly fix the problem^_^
this is the old code
from http.server import HTTPServer,BaseHTTPRequestHandler
import threading
import time
import os
f_extentions =[".py",".txt",".png",".jpg",".mp4",".mp3"]
file_list = os.listdir()
time.sleep(0.34)
class sever_l(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type","text/html")
self.end_headers()
def link():
for x in range(len(file_list)):
j = -2
ls = file_list[x]
for i in range(len(ls)):
try:
if ls[j] == ".":
ex = ls[j:]
if ex in f_extentions:
self.wfile.write(bytes("<h1>{}</h1>".format(ls),"utf-8"))
break
else:
j = j - 1
except: