how can we executed the pyscript in xampp? - html

As you know, technology was introduced as pyscript for the use of Python by html.
if you do not know: What is pyscript?
how do config that in xampp?

Quote from pyscript.net
You don't need to install anything. 😃
To use PyScript you can either download it and follow the
instructions, or add the following lines to your page.
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css"/>
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
Click here for more info on how to use PyScript.
If you don't need MySQL you can serve your DocumentRoot even without XAMPP using python itself or any other lightweight webserver:
python3 -m http.server
Then start with a simple html file. PyScript will fetch and cache its needed dependencies automatically:
<html>
<meta charset="utf-8">
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-script>
print('Hello World! 🌍')
</py-script>
</html>

Related

Hosting the build from shadow-cjls

How do i host the browser build?
I do not get it, i run:
npx shadow-cljs release app
npm start?
node app.js is wrong
I cannot launch app.js in the browser. What am i doing wrong?
My shadow-cljs.edn looks like this:
{:source-paths ["src"]
:dependencies [[binaryage/devtools "1.0.6"]
[nrepl "0.9.0"]
[reagent "1.1.1"]]
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:app {:entries [simpletodo.core]}}
:devtools {:after-load simpletodo.core/mount-root}}}
:dev-http {3000 {:root "public"
:handler user/app}}}
One level higher, i would think the index.html could be the right one, but it looks like this.
I even put in this HTML file and started the HTML, but it would not work. All i get is a white page:
➜ simpletodo cat index.html
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/css/main.css">
<title>Browser Starter</title>
</head>
<body>
<h1>shadow-cljs - Browser</h1>
<div id="app"></div>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="/public/js/app.js"></script>
</body>
</html>
Can you clarify what you mean by "hosting the build"?
If you are just testing stuff you can run npx shadow-cljs server (and keep it running) which will also run the :dev-http servers in the build config. So your files would be accessible via http://localhost:3000, just like they would be with a running watch.
A release build produces an optimized .js file. shadow-cljs is not used in production environments and is out of the picture after producing the files.
Any webserver capable of serving static files will work at that point. Common options include nginx, apache or just a CLJ webserver (eg. jetty).

How to link React.js file to html

I just installed this Create React Apps program from here https://github.com/facebookincubator/create-react-app and I have all the files downloaded and I am able to edit the App.js file, but I already have made some html files for a website, I want to know how to link the App.js file to my current files. The html on the given Index.html, shows no <script> element used. Here is the full html code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Inside your project run
npm run build
This create the folder "/build" with the "index.html" file. Inside this you can see how all this magic is done. You can put your other/old stuff also there.
I'm not entirely sure what you are asking, but you can have normal html/css on the same page as React. React is rendering the App component in the div id="root" section of the page. Elsewhere, you can just paste your old html stuff and it should work.

How does webpack rewrite HTML pages to account for automated components processing?

I am learning front-end development and currently try to understand how to use automatisation systems such as gulp, grunt or webpack. I currently picked webpack and the question is targeted to that system.
I understand its general use and built configurations to automate operations such as the compilation of .less files or minification CSS files.
The point which escapes me is that the development version of (as an example) an HTML file should differ from the production version. Specifically, my development file looks like
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>title</title>
<link rel="stylesheet" type="text/css" href="onestyle.css">
<link rel="stylesheet" type="text/css" href="anotherstyle.css">
<link rel="stylesheet" type="text/css" href="bootstrapmaybe.css">
</head>
<body>
Hello World
<script src="somelibrary.js" type="text/javascript"></script>
<script src="myown.js" type="text/javascript"></script>
</body>
</html>
while the production version is rather
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>title</title>
<link rel="stylesheet" type="text/css" href="allcssminified.min.css">
</head>
<body>
Hello World
<script src="alljsminified.min.js" type="text/javascript"></script>
</body>
</html>
where allcssminified.min.css and alljsminified.min.js are generated from the the various components of the development file, transformed though the relevant webpack mechanism into a compressed version.
There should however be one HTML file, common to development and production contexts, adapted depending on the context (dev or prod).
How should this be approached with webpack?
Through some kind of HTML templating where an if-then-else condition would include the right section?
Or should the whole <link> or <script> includes sections be somehow generated and included by webpack (which to me looks like a templating approach as well, though the decision is made by webpack?
Or should there just be one include, and the components of this include would be defined in the webpack configuration file (in that case I always get the minified version, which is possibly not optimal for debugging)
Note: there was a similar question for grunt back in 2012-2014 but the solutions listed there are not relevant to webpack and, subjectively, not very aesthetical.
CSS: I would use one main. css file (styles.css) in your application. Then #import all of the other .less or .scss files into styles.css. These will be compiled by WebPack assuming you are using the proper CSS loaders (style-loader, css-loader, less-loader).
JS: Define them in your entry config like so:
entry: ['./path/to/somelibrary.js', './path/to/myown.js']
They will get combined as well into one file.

PolymerElements, paper-icon-button to be specific, not showing up as expected

I just started with Polymer and I'm using paper-icon-button to test this out. I think I set things up correctly because the button I used have ripple effect; when I set the src property, my intended picture showed up.
<!-- This works -->
<paper-icon-button src="http://placekitten.org/g/50/50"></paper-icon-button>
However, I failed to use default icon, for example:
<!-- This does not work. There is a blank icon.
However, ripple effect still works on click -->
<paper-icon-button icon="menu"></paper-icon-button>
I ran the polymer project on a Linux server. The demo doesn't work on my computer either. Here is what the demo should look like: https://elements.polymer-project.org/elements/paper-icon-button?view=demo:demo/index.html
Here is the demo running on my polyserve:
I setup paper-icon-button using bower command instead of zip file so I would assume that all the dependencies are there. Not sure what is missing :s please help me out thanks!
You also need to import iron-icons. Look at this demo
and this example repository.
Proper way to initialize project on Windows:
Install yarn
open git bash
mkdir -p /c/projects/polymer && cd /c/projects/polymer
yarn add --dev bower
./node_modules/.bin/bower init
If you see: "bower ENOINT Register requires an interactive shell" run above command in cmd.exe. More.
./node_modules/.bin/bower install --save PolymerElements/iron-icons
./node_modules/.bin/bower install --save PolymerElements/paper-icon-button
Create index.html with content at the end of this post
yarn add --dev http-server
./node_modules/http-server
Open http://127.0.0.1:8080 in web browser
index.html:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="/bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="/bower_components/iron-icons/iron-icons.html">
<link rel="import" href="/bower_components/paper-icon-button/paper-icon-button.html">
</head>
<body>
<paper-icon-button icon="favorite" title="heart"></paper-icon-button>
</body>
</html>

replace styles.less with styles.css via git post-receive

I have a local development web with an index.html which is using:
<!-- LESS -->
<link rel="stylesheet/less" type="text/css" href="css/styles.less" />
<script src="js/lib/less-1.1.3.min.js" type="text/javascript"></script>
When I am ready editing I commit/push to my development server and the git post-receive hook runs my build.sh and builds my css / requireJS / smartsprites app.
How can I replace the above code in my static HTML file with:
<link rel="stylesheet" type="text/css" href="css/styles.css" />
without switching to server-side scripting (PHP/etc) or on the fly node.js css rendering.
In my build.sh script? With regexp? How? An example would be nice.
You can just use sed:
sed -i -e 's/styles\.less/styles\.css/g' index.html
I haven't used git-post-receive (I didn't even know it existed! thanks :P), but you could just shove it into your build.sh file or whatever file runs when you push your files to the server.