Created
November 21, 2024 23:30
-
-
Save lucasnata/16a57f49f2b7411060265228889617a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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