Skip to content

Pyue first project

First of all, we should generate project tree. Use pyue cmd tool for that:

pyue i project_name

Now you can see project structure like that:

.
├── controllers
├── main.py
├── pages
├── static
└── templates

  • controllers folder should be used to store API handlers
  • main.py file is entrypoint for your web app
  • pages folder should be used to store Pyue components
  • static folder stores images, libs and other static files
  • templates folder stores html/templates, generated by Pyue

If you look in main.py you will see an example like that:

from pyue import Pyue, BackendType, Page
from flask import Flask

# Describing page
p = Page(title="My Site")

# Creating Pyue app
app = Pyue(BackendType.Flask)

# Register page like that:
app.add_page(page=p, url="/")

f = Flask(__name__)
app.mount(f)

f.run()

As you can see:

  • Page is used to define web pages
  • Pyue is main point for web UI at all
  • Pyue.add_page(...) registers your Page components
  • Pyue.mount(...) registers itself in backend (ex. Flask)

To start our web app we must run main.py:

python main.py