Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Start a local https server with Python

Posted on 2014-11-26
4
513 Views
Last Modified: 2014-11-26
i am trying to Start a local https server with Python by doing the following but getting
>>> python -m HTTPServer 8001
SyntaxError: invalid syntax

I cant see any online docs that explain how to do this type of simple direct command?
0
Comment
Question by:pcomb
  • 3
4 Comments
 

Author Comment

by:pcomb
ID: 40467243
i also tried
import http.server
python -m http.server 8000
but still getting invalid syntax
0
 

Author Comment

by:pcomb
ID: 40467254
using 3.4.2
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 40467439
python -m http.server is run from the command line.  
C:\Users\mark>python -m http.server
Serving HTTP on 0.0.0.0 port 8000 ...

Open in new window


If you're trying to start it from within the interpreter or a script-- which based on your invalid syntax error it looks like that's what you're doing, you'd use this:
import http.server
http.server.test(HandlerClass=http.server.SimpleHTTPRequestHandler, port=8000)

Open in new window


But this isn't an HTTPS server.  It's just HTTP.  If you want HTTPS, you'd have to do something like this http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/.  That link is for Python 2 but the idea is the same for 3.  You'd need to change the underlying socket to a SSL capable one.
0
 

Author Comment

by:pcomb
ID: 40467875
great thank you
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SPSS Output Table Formatting 3 97
Python script with password security? 15 124
Parse csv file and generate graphs in HTML in bash 8 236
Need a python script 5 96
The really strange introduction Once upon a time there were individuals who intentionally put the grass seeds to the soil with anticipation of solving their nutrition problems. Or they maybe only played with seeds and noticed what happened... Som…
Flask is a microframework for Python based on Werkzeug and Jinja 2. This requires you to have a good understanding of Python 2.7. Lets install Flask! To install Flask you can use a python repository for libraries tool called pip. Download this f…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question