John Winds
John Winds

Reputation: 31

VSCode Launch Page in Local Web Server

I want VSCode to launch the HTML file I'm working on into my local testing webserver (using the ctrl-shift-b key).

I have a local web server on my Ubuntu machine running with this command: python -m SimpleHTTPServer

I have this script in my tasks.json:

{
    "version": "0.1.0",
    "linux": {
        "command": "xdg-open"
    },
    "isShellCommand": true,
    "showOutput": "never",
    "args": ["${file}"]
}

When I hit ctrl-shift-b, I get my file opened in Chrome using this path: file:///home/me/myproject/myfolder/index.html

Instead, when I hit ctrl-shift-b, I want it to launch using this URL: http://localhost:8000/myfolder/index.html

Is there any way to re-jig the tasks.json to make this happen?

I have seen some suggestions of using npm and gulp with VSCode, but I'm wondering if a simple solution like I described above can be done?

I haven't been able to find documentation for the syntax used in the tasks.json example I provided above (i.e. other options to specify instead of ${file} etc.).

Upvotes: 3

Views: 4754

Answers (1)

saranchel n
saranchel n

Reputation: 623

Go to Extension then Use the Live Server Extension. Install it from VS Code directly. You'll then have a link in the bottom of your editor to start and run the server automatically and also view your HTML immediately. Please check :live-server-web-extension and Live Server apps.

Upvotes: 3

Related Questions