Skip to content

Instantly share code, notes, and snippets.

@lucasnata
Created November 21, 2024 23:30
Show Gist options
  • Save lucasnata/16a57f49f2b7411060265228889617a1 to your computer and use it in GitHub Desktop.
Save lucasnata/16a57f49f2b7411060265228889617a1 to your computer and use it in GitHub Desktop.
def application(environ, start_response):
"""
WSGI application callable.
"""
# Configurar o status HTTP e os headers
status = '200 OK'
headers = [('Content-Type', 'text/plain')]
# Iniciar a resposta
start_response(status, headers)
# Retornar o corpo da resposta
return [b"Hello, WSGI World!"]
# Executando o servidor WSGI embutido no Python
if __name__ == "__main__":
from wsgiref.simple_server import make_server
# Cria o servidor na porta 8000
port = 8000
print(f"Serving on http://localhost:{port}")
with make_server('', port, application) as server:
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment