simplehttpserver

What is the Python 3 equivalent of “python -m SimpleHTTPServer”

瘦欲@ 提交于 2019-12-17 05:15:11
问题 What is the Python 3 equivalent of python -m SimpleHTTPServer ? 回答1: From the docs: The SimpleHTTPServer module has been merged into http.server in Python 3.0. The 2to3 tool will automatically adapt imports when converting your sources to 3.0. So, your command is python -m http.server , or depending on your installation, it can be: python3 -m http.server 回答2: The equivalent is: python3 -m http.server 回答3: Using 2to3 utility. $ cat try.py import SimpleHTTPServer $ 2to3 try.py RefactoringTool:

SimpleHTTPServer and SocketServer

有些话、适合烂在心里 提交于 2019-12-14 01:40:54
问题 I have created a 'handler' python script as follows: import SimpleHTTPServer import SocketServer PORT = 8000 Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("", PORT), Handler) print "Serving at port:", PORT httpd.serve_forever() I also have a javascript function, which sends information to the server a URL request. This all works fine, when I run my handler script, and then my javascript, I can see all of the data from the JS in the terminal: localhost

How to handle TIdHTTPServer with TIdMultiPartFormDataStream

孤街浪徒 提交于 2019-12-14 01:12:48
问题 Hi i need help on how to retrieved the parameters and data using IdHttpServer from indy. many of my application uses TIdMultiPartFormDataStream to send data over the php. I would like to use the TIdHTTPServer to verify parameters for some reason and forward the request to its destination. i created a short example for you to see. uses IdContext, IdMultipartFormData; // Server Side------------------------------------------------ IdHTTPServer1.Defaultport := 88; IdHTTPServer1.active := True;

Font awesome not loading when using Python simple http server

为君一笑 提交于 2019-12-13 05:01:42
问题 I have this simple html file that displays the thumbs down icon using font awesome. <html> <script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script> <script> WebFont.load({ custom: { families: ['FontAwesome'], urls : ['//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'] }, fontloading: function(familyName, fvd) {}, fontactive: function(familyName, fvd) {}, fontinactive: function(familyName, fvd) { }}); </script> <style type="text/css"> html{ background

Simple python server similar to SimpleHTTPServer but with PHP support? [closed]

房东的猫 提交于 2019-12-12 20:12:22
问题 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 4 years ago . I use python -m SimpleHTTPServer when I want to run my web application locally, quickly and without much pain. However, SimpleHTTPServer lacks any PHP support (or even MySQL support). Is there something similar I can do (preferably but not necessarily to do with Python) to get a quick PHP server up and running

d3 does not support cross-domain request even though after using SimpleHTTPServer

心已入冬 提交于 2019-12-12 19:19:55
问题 I want to load a tsv file from a specific directory which is different from the d3 directory. My d3 script resides under /home/meet/workspace/d3_test/scripts and SimpleHTTPServer running at "/" root. d3.tsv("http://localhost:8888/home/meet/data/data.tsv",function(error,data){ console.log("fetching data.tsv file "+error+data); }); Throwing an error: GET http://localhost:8888/home/meet/data/data.tsv 200 OK 5ms (in red color) fetching data.tsv file [object XMLHttpRequest] undefined Note:- Tried

How to use SimpleHTTPServer?

流过昼夜 提交于 2019-12-12 02:07:48
问题 I'm trying to start a simple http server with the most recent version of Python 2.7. I'm following a tutorial and it instructs me to do the following: Open the Terminal then navigate to our client directory and enter the following command: $ python -m SimpleHTTPServer But no matter what I've tried, including other codes, it doesn't work. Can anyone help please? It always puts a syntax error such as: '$' is not recognized as an internal or external command, operable program or batch file. If I

How to get client IP from SimpleHTTPServer

Deadly 提交于 2019-12-11 00:21:19
问题 Building a simple file server using the SimpleHTTPServer module in Python, however I'm running into issues when trying to get the IP from a connecting client. Here is what I have.. import SimpleHTTPServer Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("", 8080), Handler) print "Serving local directory" while True: httpd.handle_request() print Handler.client_address[0] When a client connects I get.. AttributeError: class SimpleHTTPRequestHandler has no

SimpleHTTPServer add default.htm default.html to index files

社会主义新天地 提交于 2019-12-10 23:38:42
问题 I always use $ python -m SimpleHTTPServer for fast local static web testing, it works great with index.htm or index.html as index files. However I need to use default.htm or default.html for the project I'm working on at the moment. Can someone help to write a simple script for it please? I found the below sample on the web, I hope it could help a little to get started. import sys, SimpleHTTPServer, BaseHTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler SimpleHTTPRequestHandler

Python SSL server gives me “501 Unsupported method GET”

我只是一个虾纸丫 提交于 2019-12-10 18:55:56
问题 I've followed this link to build a simple file server with SSL. from http.server import HTTPServer, BaseHTTPRequestHandler import ssl httpd = HTTPServer(('localhost', 4443), BaseHTTPRequestHandler) # openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 httpd.socket = ssl.wrap_socket (httpd.socket, keyfile="key.pem", certfile='cert.pem', server_side=True) httpd.serve_forever() I have created a certificate successfully, key.pem and cert.pem file paths are cool and I can