Mar-01-2021, 05:07 PM
(This post was last modified: Mar-02-2021, 03:32 PM by JohnnyCoffee.)
(Mar-01-2021, 03:48 PM)ndc85430 Wrote: You haven't really said what the problem is with that code. All that does is read the bytes. Does it fail in some way? Is something else not working? You don't show what you do after the read, so it's pretty hard to help. Don't make us guess!
I didn't get it right, but that's okay, follow the complete code:
from wsgiref.simple_server import make_server def hello_world_app(environ, start_response): o_file = open("cloud.png", "rb") o_file = o_file.read() status = '200 OK' # HTTP Status headers = [("Content-type", "image/png; charset=utf-8")] start_response(status, headers) # The returned object is going to be printed return [str(o_file).encode("utf-8")] with make_server('', 8000, hello_world_app) as httpd: # Function -> Imprime no terminal reference print( 'Running Kosmos Application\n' 'Browser Access - http://127.0.0.1:8000\n' 'Crl+c for flow command or Crl+z for stop' ) # Serve until process is killed httpd.serve_forever()