0

I want to ask. How to run python3 web server automatically when Raspberry Pi Reboot/ON . Plus Im using Wlan0 as my internet connection.

When I run normally in Thonny Python, it can be run.

However to make it run automatic when Raspberry Pi reboot is error [erno 99]: Cannot Assign Request Address

I trying run it in Crontab and etc/local.rc but the result is same. Error happen

This is my code:

from http.server import BaseHTTPRequestHandler, HTTPServer

class RequestHandler_httpd(BaseHTTPRequestHandler):
  def do_GET(self):
    messagetosend = bytes('Hello World!',"utf")
    self.send_response(200)
    self.send_header('Content-Type', 'text/plain')
    self.send_header('Content-Length', len(messagetosend))
    self.end_headers()
    self.wfile.write(messagetosend)
    print(self.requestline)
    return


server_address_httpd = ('172.X.X.X',8080)
httpd = HTTPServer(server_address_httpd, RequestHandler_httpd)
print('Starting Server')
httpd.serve_forever()

1 Answer 1

1

I don't know about local.rc, but using crontab -e has worked perfectly for me to start webservers like these on startup on raspberrypis.

This is the tutorial i followed, pretty straight forward. https://www.youtube.com/watch?v=zRXauWUumSI&t=64s

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.