조회 수 5324 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

python 명령어 한줄로 간단한 로컬 테스트 웹서버를 구축할 수 있다.

 

먼저 아래와 같은 명령으로 파이썬 버전을 확인한다.

python --version

 

home 디렉토리로 사용할 위치로 이동한다. (필자의 경우 윈도우 D드라이브에 "home"이라는 이름의 디렉토리를 만들었다.)

 

그다음 아래 명령을 실행한다.

 

# 위에서 반환된 파이썬 버전이 3.X인 경우

python -m http.server

 

# 위에서 반환된 파이썬 버전이 2.X인 경우

python -m SimpleHTTPServer

 

python_http.server.png

 

끝났다.

 

이제 home디렉토리에 index.html문서를 만들고 아래 코드를 작성한다.

<!DOCTYPE html>
<title>Makersweb</title>

<style>body {width: 500px;}</style>

<script type="application/javascript">
  function $init() {return true;}
</script>

<body>
  <a a href="https://makersweb.net">Welcome to the Makersweb.net</a>
  <!-- here goes the rest of the page -->
</body>

 

브라우저를 실행하고 주소란에 http://localhost:8000 을 입력하고 접속하면 아래와 같은 화면을 볼 수 있다.

index.png

 


  1. No Image

    pybind11 에 대해서

    Date2023.07.23 CategoryGeneral Bymakersweb Views5813
    Read More
  2. Qt For Python(PySide2) QML 프로젝트 예제

    Date2019.10.17 CategoryBeginner Bymakersweb Views6548
    Read More
  3. 명령어 한줄로 내컴퓨터를 웹서버로

    Date2019.01.25 CategoryGeneral By운영자 Views5324
    Read More
  4. pydbus 바인딩을 이용하여 서비스 데몬과 D-Bus통신

    Date2018.03.12 Bymakersweb Views3966
    Read More
  5. Boost Python을 이용하여 python을 위한 C++ API 바인딩

    Date2017.01.08 Bymakersweb Views11237
    Read More
  6. No Image

    [Python]EXE또는 DLL파일의 버전정보를 알아내기위한 몇가지 방법

    Date2015.06.25 Bymakersweb Views10652
    Read More
  7. QML 및 Window 투명처리

    Date2015.04.22 CategoryPyQt4 Bymakersweb Views5858
    Read More
  8. No Image

    [pyqt4]QTimer 예제 - 버튼을 누르면 3초후 함수 또는 메소드 호출

    Date2015.04.01 CategoryPyQt4 Bymakersweb Views11577
    Read More
  9. No Image

    Python + QML with PyQt4

    Date2015.03.24 CategoryPyQt4 Bymakersweb Views9619
    Read More
  10. No Image

    print를 로그파일로 생성하기 (log출력 Redirection)

    Date2015.03.18 CategoryGeneral Bymakersweb Views7430
    Read More
  11. No Image

    외부 프로그램 실행

    Date2015.02.10 CategoryGeneral Bypjk Views17032
    Read More
  12. No Image

    우분투에 Python새 버전 설치 사용법

    Date2015.02.10 CategoryGeneral Bypjk Views4863
    Read More
  13. No Image

    How to Use Freeze

    Date2014.09.06 Bypjk Views6499
    Read More
  14. No Image

    [PyQt4]개발 프로그램 버전표시 메세지 박스

    Date2014.09.02 CategoryPyQt4 Bypjk Views9404
    Read More
  15. [PyQt4]여러가지 버튼 예제

    Date2014.08.29 CategoryPyQt4 Bypjk Views19000
    Read More
  16. No Image

    Python 문자열 관련 함수 레퍼런스

    Date2014.08.29 CategoryGeneral Bypjk Views8579
    Read More
  17. [PyQt4]스레드 및 ProgressBar 예제 코드

    Date2014.08.26 CategoryPyQt4 Bypjk Views9514
    Read More
  18. No Image

    [PyQt4]multiprocess 예제 코드

    Date2014.08.26 CategoryPyQt4 Bypjk Views9326
    Read More
  19. No Image

    [PyQt4]마우스 클릭 이벤트 예제 코드

    Date2014.08.26 CategoryPyQt4 Bypjk Views7772
    Read More
  20. [PyQt4]폴더 또는 파일을 드레그하여 그 경로를 LineEdit로 가져오기

    Date2014.08.22 CategoryPyQt4 Bypjk Views14851
    Read More
Board Pagination Prev 1 2 Next
/ 2