Python Forum
http server whit proxy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
http server whit proxy
#1
Im tying to implement an httpserver for handling request and i want that request passe to another url behind proxy, so far i got this code.

import requests
import http.server
import socketserver


url = 'http://live.impresa.pt/live/sic/sic540p.m3u8'

proxies = {

    'https': 'http://80.211.204.126:443'
}
r = requests.get(url,proxies=proxies)



 class myHandler(http.server.SimpleHTTPRequestHandler):
  def do_GET(self):
    if self.path == '/sic':
        self.send_response(307)
        new_path = r.url
        self.send_header('Location', new_path)
        self.end_headers()

port = 9999
Handler = myHandler
webserver = socketserver.TCPServer(("10.0.0.110",port),Handler)
print ("Python web server ok")
webserver.serve_forever()
when i try acess 10.0.0.110:9999/sic the url is not passing to the proxy and came direct, how can i change this for the request is made behind proxy?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Paramiko Server -- Exception (server): Error reading SSH protocol banner ujlain 3 4,272 Jul-24-2023, 06:52 AM
Last Post: Gribouillis
  Socks 5 Proxy Server For UDP ASSOCIATE ankit 1 2,787 Jun-13-2023, 10:48 AM
Last Post: margaretmossman
  Server Http and Https JohnnyCoffee 2 1,926 Feb-10-2023, 12:56 AM
Last Post: Skaperen
  HTTP Server JohnnyCoffee 1 2,757 Mar-22-2021, 01:50 AM
Last Post: Larz60+
  Synchronize local mdb whit woocommerce nio74maz 0 1,708 Dec-10-2020, 12:13 PM
Last Post: nio74maz
  Add password to HTTP.server edgarfinchley 1 13,348 Aug-09-2018, 03:17 PM
Last Post: nilamo
  python -m http.server giving invalid syntax echowit 5 7,091 May-17-2018, 02:13 PM
Last Post: echowit
  newbie here - need help with building very basic http server BenSalem 0 2,355 Aug-14-2017, 08:06 AM
Last Post: BenSalem

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020