All guides

Running a web app

Run a Flask, Express or other web app on CS Room. It gets a public web address the moment it starts.

A web app, such as a Flask site or an API, runs inside your workspace. Start it in the terminal on any port, the way its tutorial says:

flask run                      # or: python app.py
node server.js
python -m http.server 8000

Within a second a notice gives its web address, such as https://quiet-sunny-harbor.app.csroom.org. Anyone can open it, so you can send it to your teacher or a friend. It works whether the app listens on localhost, 127.0.0.1 or 0.0.0.0, and links the app prints in the terminal, such as http://127.0.0.1:5000/, open the same address.

Each port keeps its address, so the link still works after you restart the app. While the app is stopped, the address says it isn't running.

Ports and names

Click Ports at the right end of the terminal's tab bar to see your servers and their addresses. Click the pencil next to an address to choose a different name. Names are 3 to 32 lowercase letters, digits and hyphens, and cannot start or end with a hyphen. Some names, such as www, api and admin, are reserved.

You can have up to 20 addresses. The trash can next to a port deletes its address, and stops the app first if it is running.

Preview a page without a server

HTML, CSS and JavaScript sites and PHP pages don't need a server of your own. Open the .html or .php file and click Preview. The page opens in a Preview tab beside your files, reloads whenever a file changes, and stays loaded while you switch back to your code.

Only you can open the preview. It serves your whole workspace with its folder layout, so relative links, stylesheets and scripts load as they would on a real site. To share the site, run a server, such as python -m http.server 8000, and share its address.

PHP pages run on PHP 8 and can use SQLite through PDO. A .php file also has a Run button, which runs it as a command-line script in the terminal.

Troubleshooting

  • "Address already in use." Another program of yours has that port. Use a different port, or stop the other program. Ports 6080, 6081 and 8888 belong to the graphical display, the Preview tab and notebooks.
  • The notice says the server has no address. You have 20 already. Remove one you no longer use in Ports.