Does IntelliJ have an internal web server to serve static content of a web application?

前端 未结 7 2543
悲&欢浪女
悲&欢浪女 2021-02-19 16:28

Right now, the directory of my module is defined as an IIS virtual directory and IIS serves the files.

I was wondering whether IntelliJ has an internal web server, whic

相关标签:
7条回答
  • 2021-02-19 17:06

    IntelliJ IDEA has a built-in web server that can be used to preview and debug your application. Just watch this YouTube video or follow the steps below.

    Option 1

    You need to add new 'JavaScript Debug' configuration:

    • Click Add Configuration... or Edit Configurations... in the Navigation bar

    • Click button in the toolbar or press Alt + Insert to create a new configuration

    • Select JavaScript Debug under the Templates node in the tree view of run configurations
    • Fill in Name, URL, Browser and click [OK] to save the configuration
      Use http://localhost:63342/YOUR-PROJECT-NAME/index.html for URL

    Now you can run the configuration:

    • Click run or debug button in the Navigation bar (or use Shift + F10 / Shift + F9 hotkeys).

    Option 2

    Running web page in browser without creating a configuration. Refer to the related IntelliJ IDEA Help article.

    1. In the editor, open the HTML file. This HTML file does not necessarily have to be the one that implements the starting page of the application.

    2. Do one of the following:

      • Choose View | Open in Browser on the main menu or press Alt+F2. Then select the desired browser from the pop-up menu.
      • Hover your mouse pointer over the code to show the browser icons bar: . Click the icon that indicates the desired browser.

    Result

    Google Chrome browser with a demo web page served by the Intelij IDEA's built-in webserver:

    0 讨论(0)
  • 2021-02-19 17:07

    UPDATE: built-in web server is available in the recent IntelliJ IDEA versions (starting from 13). You can find more details in the blog (yes, this feature first appeared in WebStorm).

    IntelliJ IDEA has no this feature, you need to install and use any third-party web server that can serve the content from the project folders.

    0 讨论(0)
  • 2021-02-19 17:09

    A built-in HTTP preview server will be part of Intellij IDEA 13 and is already available in the EAP: http://youtrack.jetbrains.com/issue/WEB-7148

    "All existing actions — preview in browser (pop-up over html file or menu action or shortcut), open in browser and create/debug html file action now open file on built-in web server http://localhost:63342/<project name>/<file path relative to source or content root>"

    In other words, right-click on an HTML page and select "Debug" or "Open in browser", and IDEA 13+ will serve up that page via port 63342.

    0 讨论(0)
  • 2021-02-19 17:09

    Here's another super simple option, install Python: http://www.python.org/getit/

    Then open a shell prompt, navigate to your root web folder (e.g. public) and run python -m SimpleHTTPServer - This starts an HTTP Service on port 8000.

    Further reading should you need it: http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python

    I've got mine running on Windows 7 but the above article still applies.

    0 讨论(0)
  • 2021-02-19 17:10

    Another option is is create a PHP project that, starting with v 5.4.0 of PHP includes a built in web server. This page explains it all ...

    http://www.jetbrains.com/idea/webhelp/php-built-in-web-server.html

    0 讨论(0)
  • 2021-02-19 17:12

    One simple way is to create a NodeJS / Express project in IntelliJ that is your web server. You can then use it to serve your static web pages and any other web content. The NodeJS web server is very small and runs fast - noticeably faster than IIS and Apache. Best of all you can just hit the Run button in IntelliJ or WebStorm to start it up.

    By default, a NodeJS / Express project includes a public/ directory that you can use to contain your static pages that you can then view from http://localhost:3000/

    This explains the steps required to enable NodeJS in IntelliJ and includes links to other Node resources: http://www.jetbrains.com/idea/webhelp/node-js.html

    If you feel the need, you can reconfigure your NodeJS server using server side Javscript code. You can add SSL support or almost any other server side features you care to dream up. Just add NodeJS modules using the npm (Node Package Manager) command line tool included with the install. NPM Registry https://npmjs.org/ indexes all the available modules.

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