How to run html file on localhost?

I have an html file and I am running it on localhost. But this file includes a mirror using a webcam. For example, how can I run this html file on localhost? Webcam starting with this example when you check the box to check. Thanks for your reply.

+20
source share
6 answers

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

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

+33
source

You can run your file in the http server .

1> You have Node.js installed.

2> In CMD, run the npm install http-server -g command

3> Go to the specific path of your file folder in CMD and run the http-server command

4> Go to your browser and enter localhost: 8080 . Your application should work there.

Thanks:)

+33
source

If you are using Python3, you can try instead:

 python -m http.server 

See this answer .

+6
source

As Nora suggests, you can use a simple python server. Browse to the folder from which you want to host your HTML page, then run python -m SimpleHTTPServer . Now you can use your web browser and go to http: // localhost: 8000 / , where your page is served. If your page is called index.html, then the server will automatically download it for you. If you want to access any other page, you need to go to http: // localhost: 8000 / {your page name}

+5
source
  • Install js node - https://nodejs.org/en/

  • go to the folder where you have the HTML file:

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

  • default port is 8080

  • Go to the browser and enter localhost:8080 . Your application should run there.

  • If you want to use a different port: http-server fileName -p 9000

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

+1
source

You can install Xampp and run apache serve, put the file in the www folder and access the file at localhost / {file name} or just localhost if your file is called index.html

0
source

All Articles