mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			GET media
							parent
							
								
									0b1e64906e
								
							
						
					
					
						commit
						48ee0cfd9f
					
				
							
								
								
									
										24
									
								
								daemon.py
								
								
								
								
							
							
						
						
									
										24
									
								
								daemon.py
								
								
								
								
							|  | @ -208,6 +208,26 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|         if self._webfinger(): |         if self._webfinger(): | ||||||
|             self.server.GETbusy=False |             self.server.GETbusy=False | ||||||
|             return |             return | ||||||
|  |         # show media | ||||||
|  |         if '/media/' in self.path: | ||||||
|  |             if self.path.endswith('.png') or \ | ||||||
|  |                self.path.endswith('.jpg') or \ | ||||||
|  |                self.path.endswith('.gif'): | ||||||
|  |                 mediaStr=self.path.split('/media/')[1] | ||||||
|  |                 mediaFilename= \ | ||||||
|  |                     self.server.baseDir+'/media/'+mediaStr | ||||||
|  |                 if os.path.isfile(mediaFilename): | ||||||
|  |                     if mediaFilename.endswith('.png'): | ||||||
|  |                         self._set_headers('image/png') | ||||||
|  |                     elif mediaFilename.endswith('.jpg'): | ||||||
|  |                         self._set_headers('image/jpeg') | ||||||
|  |                     else: | ||||||
|  |                         self._set_headers('image/gif') | ||||||
|  |                     with open(mediaFilename, 'rb') as avFile: | ||||||
|  |                         mediaBinary = avFile.read() | ||||||
|  |                         self.wfile.write(mediaBinary) | ||||||
|  |                     self.server.GETbusy=False | ||||||
|  |                     return         | ||||||
|         # show avatar or background image |         # show avatar or background image | ||||||
|         if '/users/' in self.path: |         if '/users/' in self.path: | ||||||
|             if self.path.endswith('.png') or \ |             if self.path.endswith('.png') or \ | ||||||
|  | @ -229,8 +249,8 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|                         else: |                         else: | ||||||
|                             self._set_headers('image/gif') |                             self._set_headers('image/gif') | ||||||
|                         with open(avatarFilename, 'rb') as avFile: |                         with open(avatarFilename, 'rb') as avFile: | ||||||
|                             av = avFile.read() |                             avBinary = avFile.read() | ||||||
|                             self.wfile.write(av) |                             self.wfile.write(avBinary) | ||||||
|                         self.server.GETbusy=False |                         self.server.GETbusy=False | ||||||
|                         return                     |                         return                     | ||||||
|         # get an individual post from the path /@nickname/statusnumber |         # get an individual post from the path /@nickname/statusnumber | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue