[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-18 (世界標準時間)。"],[],[],null,["# Preview web apps\n\nThis page describes how to use the web preview feature in Cloud Shell.\nThis feature allows you to run web applications on the Cloud Shell virtual\nmachine instance and preview them from the [Google Cloud console](https://console.cloud.google.com/).\n\nThe Web Preview button\ncan be found on the top right of the Cloud Shell taskbar.\n\nStart the web application\n-------------------------\n\nYou can run any web application that listens to HTTP requests on the\nCloud Shell virtual machine, including the App Engine development server. The web\napplication must listen for HTTP requests on ports within the permitted range\n2000 to 65000. These ports are only available to the secure Cloud Shell proxy\nservice, which restricts access over HTTPS to your user account only.\n\n### Simple server example\n\nTo start a simple Python HTTP server from the Cloud Shell command\nprompt: \n\n```sh\ncd `mktemp -d` \\\n && echo '\u003chtml\u003e\u003cbody\u003eHello World\u003c/body\u003e\u003c/html\u003e' \u003e./index.html \\\n && python -m http.server 8080\n```\n\n### App Engine development server example\n\nTo clone a sample App Engine application and run it on the\nApp Engine development server: \n\n```sh\ngit clone https://github.com/GoogleCloudPlatform/appengine-guestbook-python \\\n && cd appengine-guestbook-python \\\n && dev_appserver.py ./app.yaml\n```\n\nThe development server runs on port 8080 by default.\n\nPreview the application\n-----------------------\n\nClick the **Web Preview** button\nand then select\nthe port number from the displayed menu. Cloud Shell opens the preview URL on\nits proxy service in a new browser window.\n\nYou can also access the preview URL by combining the port with the environment\nvariable `WEB_HOST` in the Cloud Shell terminal using the format `https://$PORT-$WEB_HOST`,\nor by using the [Cloud Shell API](/shell/docs/reference/rpc/google.cloud.shell.v1#environment).\n\nAccessing Streamlit applications\n--------------------------------\n\nWeb preview in Cloud Shell works through a series of HTTP proxies.\nStreamlit applications require [additional arguments](https://github.com/streamlit/streamlit/issues/6305) to function when running\nbehind an HTTP proxy. When running these applications, make sure you specify\n`--browser.serverAddress=localhost --server.enableCORS=false --server.enableXsrfProtection=false`\non the command line."]]