1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python 3 simple HTTP server with GET functional

Discussão em 'Python' iniciado por Stack, Setembro 16, 2024.

  1. Stack

    Stack Membro Participativo

    I can't find any Python code for the equivalent of

    python -m http.server port --bind addr --directory dir


    So I need basically a working server class that process at least GET requests. Most of the things I found on Google were either an HTTP server with some special needs or something like that, where you need to code the response behaviour be yourself:

    from http.server import BaseHTTPRequestHandler, HTTPServer

    def run(server_class=HTTPServer, handler_class=BaseHTTPRequestHandler):
    server_address = ('', 8000)
    httpd = server_class(server_address, handler_class)
    httpd.serve_forever()

    run()


    All that I need is a default working skeleton of a Python HTTP server, where you can provide address, port and directory, and it would normally process GET requests.

    Continue reading...

Compartilhe esta Página