How to run html file on localhost?

后端 未结 8 673
再見小時候
再見小時候 2020-12-04 08:41

I have a html file and i run it on localhost. But, this file includes mirror using webcam. Example, how can i run this html file on localhost? Webcam starting on this exampl

相关标签:
8条回答
  • 2020-12-04 09:17

    As Nora suggests, you can use the python simple server. Navigate to the folder from which you want to serve your html page, then execute python -m SimpleHTTPServer. Now you can use your web-browser and navigate to http://localhost:8000/ where your page is being served. If your page is named index.html then the server automatically loads that for you. If you want to access any other page, you'll need to browse to http://localhost:8000/{your page name}

    0 讨论(0)
  • 2020-12-04 09:18

    You can try installing one of the following localhost softwares:

    1. xampp
    2. wamp
    3. ammps server
    4. laragon

    There are many more such softwares but the best among them are the ones mentioned above. they also allow domain names (for example: example.com)

    0 讨论(0)
  • 2020-12-04 09:21

    On macOS:

    Open Terminal (or iTerm) install Homebrew then run brew install live-server and run live-server.

    You also can install Python 3 and run python3 -m http.server PORT.

    On Windows:

    If you have VS Code installed open it and install extension liveserver, then click Go Live in the bottom right corner.

    Alternatively you can install WSL2 and follow the macOS steps via apt (sudo apt-get).

    On Linux:

    Open your favorite terminal emulator and follow the macOS steps via apt (sudo apt-get).

    0 讨论(0)
  • 2020-12-04 09:23

    You can use python -m http.server. By default the local server will run on port 8000. If you would like to change this, simply add the port number python -m http.server 1234

    If you are using python 2 (instead of 3), the equivalent command is python -m SimpleHTTPServer

    0 讨论(0)
  • 2020-12-04 09:29
    • Install Node js - https://nodejs.org/en/

    • go to folder where you have html file:

      • In CMD, run the command to install http server- npm install http-server -g
      • To load file in the browser run - http-server
    • If you have specific html file. Run following command in CMD.- http-server fileName

    • by default port is 8080

    • Go to your browser and type localhost:8080. Your Application should run there.

    • If you want to run on different port: http-server fileName -p 9000

    Note : To run your .js file run: node fileName.js

    0 讨论(0)
  • 2020-12-04 09:38

    If you are running Python3, you may want to instead try:

    python -m http.server
    

    See this answer.

    0 讨论(0)
提交回复
热议问题