Skip to main content

aldServer - a template server

Inspired by Flask and Jinja. Super easy to use!

Installation

pip3 install aldSever

Simple Code Example

# imports
from aldServerimport createServer, Route, Debug
from aldServerimport RESPONSE, CONTENT_TYPE, CHARSET

# server debugging (false by default)
Debug.debug = True 

# crete route obj
route = Route()

# create static folder 
route.static_folder('/static')

# create simple route
@route.create_route('/api/v2/json', CONTENT_TYPE.JSON, RESPONSE.OK, CHARSET.UTF8)
def json_test():
    return "{'json': 'is the best'}"

# simple templating, passing arguments
@route.create_route('/me', CONTENT_TYPE.TEXT_HTML, RESPONSE.OK, CHARSET.UTF8)
def template_test():
    return route.render_template('/me.html', name="aldison")
    ''' - me.html file:
       <h3>Hello my name is {{%name%}},</h3>
       <h4>and this server is made with aldServer.</h4> 
    '''
    ''' - me.html file after rendering
       <h3>Hello my name is aldison,</h3>
       <h4>and this server is made with aldServer.</h4> 
    '''

# create the server
server = createServer(hostname="localhost", port=3333)
# run the creted server
server.run()

Template Supports

  • Different loops:
#1 -  to_dos - is given as a parameter
{%for to_do in to_dos%}
    <li>{{to_do}}</li>
{%endloop%}

#2
{%for i in range(5)%}
    <li>{{i}}</li>
{%endloop%}

#3
{%for i, x in enumerate(range(5))%}
    <li>{{i}} - {{x}}</li>
{%endloop%}

#4
{%for i in range(5)%}
    {{ i }} x 7 = {{i * 7}} <br>
{%endloop%}

#5
{%for item in ["hello", "world"]}
    <li>{{item}}</li>
{%endloop%}
  • Printing variables
<h3>Hello my name is {{%name%}},</h3>
<h4>and this server is made with aldServer.</h4> 

Download files

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

Source Distribution

aldServer-0.0.2.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file aldServer-0.0.2.tar.gz.

File metadata

  • Download URL: aldServer-0.0.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for aldServer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 846a99c1b1087b8afe314ff9ef85559430f7c3eaed33705fb0b423fa1f6bfe37
MD5 aaac39018a390fc15cdc55dd33c82d47
BLAKE2b-256 009670ae3c6c9998d3d778a76f7b8ac0f2282fa05159e4128917dbd26ae26175

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 file

0.0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page