Skip to main content

a fast and simple micro-framework for small web applications

Project description

eweb

eweb(easy web) is a fast and simple micro-framework for small web applications. Its goal is to enable you to develop web applications in a simple and understandable way.

With it, you don't need to know the HTTP protocol, or how Python communicates with JavaScript.

Usage

Step1

Create a file, such as main.py:

from eweb import Server


def hello(name):
    return 'hello %s!' % name


if __name__ == '__main__':
    server = Server(port=5000)
    server.services['hello'] = hello

    server.run()

Step2

  1. Create a folder named static
  2. Create a HTML file in the static folder, such as index.html:
<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <title>index</title>
   <script src="/service.js"></script>
</head>
<body>
<script>
   //say hello
   service.call('hello', {'name': 'eweb'}, function(data){
       alert(data);
       /**
       ...
       Anything you want to do
       ...
       */
   });
</script>
</body>
</html>

Step3

Run the main.py. Then, visit http://localhost:5000/index.html in your browser. You will get alert message "hello eweb!".

It's also easy if you want to develop desktop applications with eweb. At this point, usually, you need a callback function and a random port to start the server. What you need to do will be like this:

from eweb import Server


def hello(name):
    return 'hello %s!' % name


def callback():
    print('Server startup completed!')
    import webbrowser
    webbrowser.open('http://localhost:%s/index.html' % server.port)
    

if __name__ == '__main__':
    server = Server(port=None)
    server.services['hello'] = hello

    server.run()

Run main.py, then, after the server is started, the index.html page will open automatically in the browser.

Note

The static folder is a resource folder, and files under this folder can be accessed directly. So, usually, HTML, CSS, and JavaScript files should be placed in this folder, and other private files should not be placed in this folder.

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

eweb-0.0.6.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file eweb-0.0.6.tar.gz.

File metadata

  • Download URL: eweb-0.0.6.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for eweb-0.0.6.tar.gz
Algorithm Hash digest
SHA256 f3c92de29dd1dd1b7483148bb148657a0a3b9c51a084a8143693c7eec37cb904
MD5 f043af58852e60cbce98acf1220b86d8
BLAKE2b-256 3ca678a6c2ea68db3a9cbabc15c6ef4f6ad7c2c60f349257697498f79d3f9757

See more details on using hashes here.

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