close
  • Ko chevron_right

    Comment exécuter du Python dans une page web ?

    news.movim.eu / Korben · Tuesday, 24 August - 07:00 · 1 minute

Bon, le JavaScript vous voyez ce que c’est. C’est un langage interprété qui permet de lancer du code directement via les pages web que nous consultons.

Cool.

Bon, et maintenant si je vous disais qu’on peut faire exactement la même chose, mais en Python ?

Vous me dites : SORCELLERIE !!!

Et vous avez raison. N’empêche que c’est totalement faisable grâce à Brython. Brython est une implémentation de Python 3 fonctionnant dans le navigateur, avec une interface pour les éléments DOM et les événements.

Voici un bout de code de ce que ça donne :

    <html>        <head>            <script type="text/javascript" src="/path/to/brython.js"></script>        </head>        <body onload="brython()">            <script type="text/python">            from browser import document, alert            def echo(event):                alert(document["zone"].value)            document["mybutton"].bind("click", echo)            </script>            <input id="zone"><button id="mybutton">click !</button>        </body>    </html>

Il suffit donc de charger dans la page le fichier brython.js puis d’appeler la fonction brython() au chargement de la page pour ensuite pouvoir fourrer du code Python dans une balise script comme vous le feriez en JavaScript. Un tutoriel est dispo ici .

Magique non ?

Brython supporte la syntaxe de Python 3, y compris les compréhensions de listes, les générateurs, les métaclasses, les importations, etc. et de nombreux modules de la distribution CPython.

Brython dispose de bibliothèques pour interagir avec les éléments DOM et les événements, ainsi qu’avec les bibliothèques JavaScript existantes telles que jQuery, D3, Highcharts, Raphael, etc. Il prend en charge les dernières spécifications de HTML5/CSS3, et peut utiliser des cadres CSS comme Bootstrap3, LESS, SASS, etc.

Bref, c’est de la bonne.

D’ailleurs, si vous voulez voir ce que ça donne, il y a une belle page d’exemples avec code source ici .

Ça peut vous permettre surtout d’utiliser du code existant dans des pages web sans devoir tout vous retaper à réécrire en JS. Et ça, c’est beau.

Si vous voulez plus d’infos sur Brython, c’est par ici que ça se passe .

KorbensBlog-UpgradeYourMind?d=yIl2AUoC8zAKorbensBlog-UpgradeYourMind?i=BTftKnUY9wM:1tM1ytFvZQI:D7DqB2pKExkKorbensBlog-UpgradeYourMind?i=BTftKnUY9wM:1tM1ytFvZQI:GG6oivYVkFsKorbensBlog-UpgradeYourMind?d=qj6IDK7rITsKorbensBlog-UpgradeYourMind?i=BTftKnUY9wM:1tM1ytFvZQI:gIN9vFwOqvQKorbensBlog-UpgradeYourMind?d=7Q72WNTAKBA
  • Pictures 1 image

  • visibility
  • In chevron_right

    How to use Auth0 with Node.js and Express

    pubsub.slavino.sk / infoworldcom · Thursday, 19 August - 10:00 edit

Cloud-based authentication and authorization platforms—sometimes known as IDaaS, or identity as a service — are an expanding area of cloud tooling, and it’s easy to see why. App security is difficult and error-prone, and virtually every project requires it. The ability to offload much of the work to a dedicated and proven service is enticing.

Auth0 is an up-and-coming provider of authentication and authorization services (and open source software ). In this article, you will see how to incorporate Auth0 log-in capabilities into a app with a Node.js/Express back end, serving a straight JS front end, and then use the authenticated user info (via JWT) to show/hide UI information and secure RESTful endpoints.

To read this article in full, please click here


Značky: #JavaScript, #Rozne, #Node.js

  • In chevron_right

    TypeScript 4.4 brings performance boosts

    pubsub.slavino.sk / infoworldcom · Monday, 16 August - 19:49 edit

Microsoft’s TypeScript 4.4, the latest planned version of its popular typed version of JavaScript , has moved to a release candidate stage, with capabilities including performance improvements and control flow analysis.

No further changes are expected in the release apart from critical bug fixes.

For faster declaration emits, TypeScript now caches whether internal symbols are accessible in different contexts, along with how specific types are to be printed. This improves general performance in code with fairly complex types.

[ Also on InfoWorld: 7 tools transforming JavaScript development ]

Other performance enhancements in TypeScript 4.4 promise faster path normalization and path mapping, along with faster incremental builds. An optimization has been added for source map generation of very large output files, and faster --force builds are offered as well. A -- force build does not need up-to-date checks to determine which files need to be rebuilt, with project dependencies rebuilt from scratch.

To read this article in full, please click here


Značky: #Rozne, #Typescript, #JavaScript

  • In chevron_right

    Angular 13 begins to take shape

    pubsub.slavino.sk / infoworldcom · Friday, 13 August - 21:16 edit

Angular 13, a planned upgrade to Google’s popular TypeScript-based web framework, is starting to take shape. Two beta releases, published on August 4 and August 11 and accessible on GitHub , introduce changes to forms and the router.

For forms, Angular 13 debuts a new type, FormControlStatus , which is a union of all possible status strings for form controls. Also, AbstractControl.status has been narrowed from string to FormControlStatus and StatusChanges have been narrowed from Observable<any> to Observable<FormControlStatus> . Most applications should consume these new types seamlessly, according the Angular changelog.

To read this article in full, please click here


Značky: #Angular, #JavaScript, #Typescript, #Rozne

  • In chevron_right

    Visual Studio 2022 Preview 3 shines on JavaScript, TypeScript, Git

    pubsub.slavino.sk / infoworldcom · Friday, 13 August - 10:00 edit

With the third preview of Microsoft’s planned 64-bit Visual Studio 2022 IDE, the company is emphasizing a new JavaScript/TypeScript experience as well as multi-repo support.

Unveiled August 10, Visual Studio 2022 Preview 3 also covers themes including personal and team productivity. For JavaScript and TypeScript , the preview offers tools to enhance the experience for single-page applications and front-end development. A new JavaScript/TypeScript project will enable developers to build standalone Angular , React , and Vue projects. Visual Studio will leverage each JavaScript framework’s native CLIs to front-end project templates. The IDE will discover the version of the CLI installed on the developer’s path to scaffold the project.

To read this article in full, please click here


Značky: #Typescript, #JavaScript, #Rozne

  • In chevron_right

    Vue 3.2 promises speed boost

    pubsub.slavino.sk / infoworldcom · Wednesday, 11 August - 18:16 edit

Vue 3.2, a new release of the popular JavaScript framework, offers better performance as well as improvements to single file components and web components. Vue 3.2 was announced on August 5.

With the upgrade, Vue’s reactivity system , which is intended to simplify state management , gains a more efficient ref implementation, faster dependency tracking, and lower memory usage. Performance of the template compiler also has been improved, with faster creation of Vnodes (virtual nodes). A new v-memo directive provides the ability to “memoize” part of the template tree. A v-memo hit lets Vue skip virtual DOM diffing and the creation of new Vnodes altogether. This capability can improve performance in certain scenarios, such as large v-for lists.

To read this article in full, please click here


Značky: #Vue, #Rozne, #JavaScript

  • In chevron_right

    How to use FilePond with Node.js

    pubsub.slavino.sk / infoworldcom · Thursday, 29 July - 10:00 edit

Uploading files is a common need for cloud apps. FilePond is a solid open-source project that offers sophisticated file handling and wrappers for many JavaScript frameworks like React and Svelte .

This article gives an overview of handling file uploads with FilePond and a Node.js and Express back end.

[ Also on InfoWorld: How to CRUD with Node.js and MongoDB ]

Why FilePond?

There are numerous libraries available for the task, but FilePond is supremely easy to use and handles niceties like image optimization without extra configuration. Moreover, it gives the developer a clear-cut process on the server-side.

To read this article in full, please click here


Značky: #JavaScript, #Rozne, #Node.js