Search code examples
pythondjangoseleniumtwilio-apihttpserver

How to automatically start a python http server


I am using python http.server 80 to expose my downloaded files to my twilio whatsapp bot is there a way that as my django-twillio app starts it automatically runs the server on port 80 as well python -m http.server 80


Solution

  • Adding this code to your django-twilio app will programmatically start your server on localhost:80

    from http.server import HTTPServer, SimpleHTTPRequestHandler
    
    httpd = HTTPServer(('localhost', 80), SimpleHTTPRequestHandler)
    httpd.serve_forever()