Starting-up

In the Installation and Setup section the sample index.html file generated by anpylar-application was shown. Let’s recall it

<!DOCTYPE html>
<html>
<head>
  <title></title>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="styles.css">
  <script src="anpylar.js" async></script>

</head>
<body></body>
</html>

There is something which probably catches the eye:

No Python script is defined.

Being the question then: How does the start-up process work?

Note

Anyone familiar with Brython (the underlying technology) will notice that a brython() call is needed to kickstart everythin when when the body is loaded.

This is all automatically managed by AnPyLar when everything is ready.

Automatic Start-Up

If no Python snippets or links to them are specified in index.html, AnPyLar will do the following for you

import app

app.AppModule()

This can of course be overridden by the end user by using specific python scripts which kickstart the application. The ìmport app ... auto-call matches the code auto-generated by the AnPyLar command line interface.

User controlled Start-Up

If AnPyLar detects that the user has specified a script it will honour it.

Just place script somewhere in index.html like in:

<!DOCTYPE html>
<html>
<head>
  <title></title>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="styles.css">
  <script src="anpylar.js" async></script>

  <script type="text/python3">
    from myapp import run
    run()
  </script>
</head>
<body></body>
</html>

Note

You can use text/python or text/python3 for the type.

or place a link to the script as in

<!DOCTYPE html>
<html>
<head>
  <title></title>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="styles.css">
  <script src="anpylar.js" async></script>

  <script type="text/python3" src="/mypath/myapp.py"></script>
  </script>
</head>
<body></body>
</html>