mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
update getting started
This commit is contained in:
@@ -35,9 +35,11 @@ HTML file.
|
|||||||
To demonstrate the above, let's start from the most popular "first application example": let's write a "Hello, world!"
|
To demonstrate the above, let's start from the most popular "first application example": let's write a "Hello, world!"
|
||||||
example using PyScript.
|
example using PyScript.
|
||||||
|
|
||||||
Using your favorite editor, create a new file called `hello.html` and paste in the following content:
|
Using your favorite editor, create a new file called `hello.html` and paste in the following content and open it in your web browser. (You can typically
|
||||||
|
open an HTML by double-clicking it in your file explorer.):
|
||||||
|
|
||||||
```html
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
@@ -59,10 +61,9 @@ Using your favorite editor, create a new file called `hello.html` and paste in t
|
|||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
and open it in your web browser. (You can typically
|
<a href="https://fpliger.pyscriptapps.com/hello-world-minimal-example/latest/" target="_blank">or open this example on pyscript.com</a>
|
||||||
open an HTML by double-clicking it in your file explorer.)
|
|
||||||
|
|
||||||
You should see "Hello World!" printed on your page and your Javascript Console (don't worry if
|
You should see "Hello World!" printed in your page and in your Javascript Console (don't worry if
|
||||||
you don't know what it means yet, we'll get into that later).
|
you don't know what it means yet, we'll get into that later).
|
||||||
|
|
||||||
## Serving your application
|
## Serving your application
|
||||||
@@ -77,21 +78,11 @@ and the [browser developer console](https://balsamiq.com/support/faqs/browsercon
|
|||||||
error like *"Cross origin requests are only supported for HTTP."*
|
error like *"Cross origin requests are only supported for HTTP."*
|
||||||
|
|
||||||
In short, when browsers visualize a web page, they expect them to be served by a
|
In short, when browsers visualize a web page, they expect them to be served by a
|
||||||
web server. Here are a few options that we can use to fix this issue:
|
web server.
|
||||||
|
|
||||||
**NOTE:** If you are an experienced developer and already know how to host and serve files on a [static]
|
For the rest of this documentation, we'll be presenting examples and snippets and host them on
|
||||||
web server, feel free to skip to the next section.
|
pyscript.com. Users can reference the [serving your application](serving-your-application.md) at
|
||||||
|
anytime for other options.
|
||||||
### Using a Local Server
|
|
||||||
|
|
||||||
A very common fix for this is to use a [simple local server](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Tools_and_setup/set_up_a_local_testing_server) to make your html file available to the browser.
|
|
||||||
|
|
||||||
|
|
||||||
If you have python installed on your system, you can use it's basic built-in server for this purpose via the command line.
|
|
||||||
Change the current working directory of your terminal or command line to the folder where your HTML file is stored.
|
|
||||||
From this folder, run `python -m http.server 8080 --bind 127.0.0.1` in your terminal or command line. With the server
|
|
||||||
program running, point your browser to `http://localhost:8080` to view the contents of that folder. (If a file in
|
|
||||||
that folder is called `index.html`, it will be displayed by default.)
|
|
||||||
|
|
||||||
## A more complex example
|
## A more complex example
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user