Home > front end >  Under the new turn of questions about python wsgi servers
Under the new turn of questions about python wsgi servers

Time:10-06

Their reference online tutorials wrote a wsgi servers, but found that load the home page, images load not to come out, and woff and couldn't load the vera.ttf style,

Look at the program run results found that no matter how change, picture or not to,,,
` ` `
# image style
If the path. The startswith ("/static/images ") :
# to allow access to static files
File_name=path (14:)
# to open the file, read content
Try:
The file=open (IMAGE_ROOT_DIR + file_name, "rb")
Except IOError:
# for the routing information is not found, 404 error
The status="404 Not Found"
Headers=[]
Start_response (status, headers)
Return "not Found" + file_name
The else:
File_data=(https://bbs.csdn.net/topics/file.read)
File. The close ()

The status="200 OK"
Headers=[]
Start_response (status, headers)
Return file_data
` ` `

Then I write a test program, I found my writing can be read, but to the server to open the homepage there just don't know why, and you won't come
` ` `
F=open ("../HTML/fonts/glyphicons halflings - regular. The vera.ttf ", "rb")
Data=(https://bbs.csdn.net/topics/f.read)
Print (type (data))
Print (data)
F. lose ()
` ` `
Pictures are all hung over there,,,


This is a program to print mistake:


I know you must want to say to decode,,, but the decode is useless,,,


Pictures did not come out



Have bosses to sprout new explain how to solve,,
  • Related