simplehttpserver

How do I forward a request to a different url in python

倾然丶 夕夏残阳落幕 提交于 2019-12-02 20:37:06
I have been looking for the syntax to redirect a special url to a remote server to do some XSS testing. Any ideas? import SimpleHTTPServer import SocketServer class myHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): def do_GET(self): print self.path if self.path == '/analog': -------------------->return "http://12b.dk/analog"??? return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) theport = 1234 Handler = myHandler pywebserver = SocketServer.TCPServer(("", theport), Handler) print "Python based web server. Serving at port", theport pywebserver.serve_forever() For a redirect, you

BasicHTTPServer, SimpleHTTPServer and concurrency

隐身守侯 提交于 2019-12-01 18:52:32
I'm writing a small web server for testing purposes using python, BasicHTTPServer and SimpleHTTPServer. It looks like it's processing one request at a time. Is there any way to make it a little faster without messing around too deeply? Basicly my code looks as the following and I'd like to keep it this simple ;) os.chdir(webroot) httpd = BaseHTTPServer.HTTPServer(("", port), SimpleHTTPServer.SimpleHTTPRequestHandler) print("Serving directory %s on port %i" %(webroot, port) ) try: httpd.serve_forever() except KeyboardInterrupt: print("Server stopped.") Alex Martelli You can make your own

Python SimpleHTTPServer in production

天涯浪子 提交于 2019-12-01 14:45:22
问题 I want to serve static files with Python. Is the Python 3 http.server suitable for use in production? If not, why not? And what are my alternatives? 回答1: Quoting documentation https://docs.python.org/3/library/http.server.html#module-http.server Warning: http.server is not recommended for production. It only implements basic security checks. First of all you don't need python at all to serve static files. Just use a real HTTP Server like Apache or NGinx. If you want a quick solution just look

Audio/Video streaming fails using SimpleHTTPServer [closed]

▼魔方 西西 提交于 2019-12-01 14:09:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I share files in a folder to other devices by invoking a server using python -m SimpleHTTPServer . I just tried to stream videos/audio (standard mp4 & mp3, both under 20MB) to another computer using this & it WORKS (but by throwing the errors (listed down) in the terminal). Somehow, the video/audio fails (except

Save logs - SimpleHTTPServer

最后都变了- 提交于 2019-11-30 03:32:29
问题 How can I save the output from the console like "192.168.1.1 - - [18/Aug/2014 12:05:59] code 404, message File not found" to a file? Here is the code: import SimpleHTTPServer import SocketServer PORT = 1548 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("", PORT), Handler) print "serving at port", PORT httpd.serve_forever() 回答1: BaseHTTPRequestHandler.log_message() prints all log messages by writing to sys.stderr . You have two choices: 1) Continue using

How to run a http server which serve a specific path?

。_饼干妹妹 提交于 2019-11-28 18:12:54
this is my Python3 project hiearchy: projet \ script.py web \ index.html From script.py , I would like to run a http server which serve the content of the web folder. Here is suggested this code to run a simple http server: import http.server import socketserver PORT = 8000 Handler = http.server.SimpleHTTPRequestHandler httpd = socketserver.TCPServer(("", PORT), Handler) print("serving at port", PORT) httpd.serve_forever() but this actually serve project , not web . How can I specify the path of the folder I want to serve? https://docs.python.org/3/library/http.server.html#http.server

How do I shut down a python simpleHTTPserver?

落爺英雄遲暮 提交于 2019-11-28 15:34:20
So I'm trying to learn d3, and the wiki suggested that To view the examples locally, you must have a local web server. Any web server will work; for example you can run Python's built-in server: python -m SimpleHTTPServer 8888 & Great... only now I have a server running... but at some point I think I should probably shut that down again. Is there a better way of shutting it down than using kill <pid> ? That seems like kind of a big hammer for a little job. (I'm running Mac OS 10.6.8 (Snow Leopard)) FWIW: ctrl+c gives about 10 lines of traceback, complaining about being interrupted. kill -3

Enable access control on simple HTTP server

大兔子大兔子 提交于 2019-11-28 15:26:53
I have the following shell script for a very simple HTTP server: #!/bin/sh echo "Serving at http://localhost:3000" python -m SimpleHTTPServer 3000 I was wondering how I can enable or add a CORS header like Access-Control-Allow-Origin: * to this server? Unfortunately, the simple HTTP server is really that simple that it does not allow any customization, especially not for the headers it sends. You can however create a simple HTTP server yourself, using most of SimpleHTTPRequestHandler , and just add that desired header. For that, simply create a file simple-cors-http-server.py (or whatever) and

Python SimpleHTTPServer

那年仲夏 提交于 2019-11-28 11:28:28
Is there a way to make Python SimpleHTTPServer supports mod_rewrite? I'm trying things with Ember.js with leveraging History API as the location API, and to make it work, I have to : 1) add some vhosts config in WAMP (not simple), or 2) run python -m simpleHTTPServer (very simple) So when I opened it in the browser, localhost:3000 and clicked around the navigation (about and users for example), it worked well. The URLs are changed by Ember.js to localhost:3000/about and localhost:3000/users respectively. But when I tried to open localhost:3000/about directly in new tab, the python web server

How to host python cgi script with `python -m SimpleHTTPServer 8000` or `python -m CGIHTTPServer 8000`?

混江龙づ霸主 提交于 2019-11-28 08:12:17
When I run python -m SimpleHTTPServer 8000 or python -m CGIHTTPServer 8000 in my shell I am hosting the content of my current directory to the internet. I would like to make the following cgi_script.py work correctly using the above command in the command line when I browse to 192.xxx.x.xx:8000/cgi_script.py #!/usr/bin/env python print "Content-Type: text/html" print print """\ <html> <body> <h2>Hello World!</h2> </body> </html> """ But this script is displayed literally and not only the "Hello World!" part. Btw I changed the file permissions to 755 for cgi_script.py as well as the folder I am