Skip to main content

A simple to use Framework with a Python syntax that can replace HTML in a comfortable and easy way.

Project description

phyal

Static Badge

A simple to use Framework with a Python syntax that can replace HTML in a comfortable and easy way.


phyal is easily used with the template, otherwise it requires some setup.

So first you have to import the necessary files ->

import phyal

and in the shell

pip install phyal

Then you will have to define a route/source, for example ->

app = App()

@app.route('/')
def index(request):

and now you can add links to other files like JavaScript and CSS ->

css_link = '<link rel="stylesheet" type="text/css" href="/static/style.css">'
js_link = '<script src="/static/script.js"></script>'

html_content = [
    css_link, js_link
]

Outside of your route you need to allow the file to be ran ->

if __name__ == '__main__':
    app.run('0.0.0.0', 5000)

Now you can code away using phyal in your route.


Syntax

phyal components go hand in hand with HTML elements but are written in the Python programming language.

You can use an element by setting up an advised html_content list ->

html_content = [
    css_link, js_link,
    str(Tag()) # Element
]

you can then add your element (currently select few, but most/all elements will be added eventually) to the line, for example the paragraph element or <p> ->

str(Tag('p', 'Hello World'))

The first set of parentheses on all elements is for text (if it is used withen HTML, think <a> tags, or <h1> tags, etc.)

Then you can add attributes, things like HREF's SRC's ALT's would fall in this category. You would add .attribute(# attribute()) to your line, for example an <a> tag ->

str(Tag('a', 'Link', href='https://google.com'))

You can use the phyal framework along side things like JavaScript and CSS and add ID's like so .id(''), for example with a <p> tag ->

str(Tag('p', 'Hello World', id='my_id'))

You can also add children to the elements in a hireachy system like HTML like so .add_children(Tags.) # Element, for example a <p> tag ->

str(Tag('p', 'Hello World', children=[
    Tag('div', children=[
        # Add more children here if needed
    ])
]))

Running

Once you have written out your code with phyal you can either write it where it runs once or runs continuously (harder on preformance, but works with JS better)

Single Use

return Response(html_content, content_type='text/html')

Continuously

while True:
    app.reload_content(html_content)
    return Response(html_content, content_type='text/html')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phyal-0.3.0.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

phyal-0.3.0-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page