Skip to main content

Python API for WebFramework

Project description

C++ HTTP/HTTPS server with Python API

Quick start

Server needs few files to run:

main.py

from web_framework_api.WebFramework import WebFramework  # Server
from web_framework_api.utility.DLLHandler import initialize_web_framework  # WebFramework initialization 
from web_framework_api.exceptions.WebFrameworkException import WebFrameworkException  # Exception

def on_start():
  print("Server is running")

if __name__ == '__main__':
  try:
    initialize_web_framework()  # Load WebFramework shared library

    server = WebFramework.from_path("config.json")  # Create server

    server.start(True, on_start)  # Start server and wait
  except WebFrameworkException as exception:
    print(exception)

    exit(-1)

Settings

web.json

{
  "HelloExecutor": {
    "route": "",
    "loadType": "initialization",
    "api": "python"
  }
}

Config

config.json

{
  "WebServer": {
    "ip": "0.0.0.0",
    "port": 8080,
    "timeout": 0
  },
  "WebFramework": {
    "settingsPaths": [
      "web.json"
    ],
    "loadSources": [
      "hello_executor"
    ],
    "runtimes": [
      "python"
    ],
    "assetsPath": "assets",
    "templatesPath": "templates",
    "cachingSize": 536870912,
    "webServerType": "multiThreaded",
    "HTTPS": {
      "useHTTPS": false,
      "pathToCertificate": "certificates/cert.pem",
      "pathToKey": "certificates/key.pem"
    },
    "defaultAssetsPath": "WebFrameworkAssets"
  },
  "Logging": {
    "usingLogging": false,
    "dateFormat": "DMY",
    "logFileSize": 134217728
  },
  "ThreadPoolServer": {
    "threadCount": 0
  }
}

Run sample

After running server open url 127.0.0.1:8080.
You will see response from server

{
  "message": "Hello, World!"
}

Executors

Executors are C++, C, Python or C# classes that responsible for giving responses for their route(url).
Source code of HelloExecutor from example
hello_executor.py

from web_framework_api import *

class HelloExecutor(StatelessExecutor):
    def do_get(self, request, response):
        response.set_body({
            "message": "Hello, World!"
        })

More information you can find in wiki.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

web_framework_api-3.3.4-cp314-cp314-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.14Windows x86-64

web_framework_api-3.3.4-cp314-cp314-manylinux_2_34_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

web_framework_api-3.3.4-cp313-cp313-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.13Windows x86-64

web_framework_api-3.3.4-cp313-cp313-manylinux_2_34_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

web_framework_api-3.3.4-cp312-cp312-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.12Windows x86-64

web_framework_api-3.3.4-cp312-cp312-manylinux_2_34_x86_64.whl (14.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

Details for the file web_framework_api-3.3.4-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 74e7d7f1259bebfc5936094be3c4a22089f841c7a753bb434b1b85decec4ab79
MD5 8a2d61e509018ce9f73e73d388aa9b58
BLAKE2b-256 76f4bba016f0011f7881af3876782dc0290b508075622110d318e9e6d43f81b1

See more details on using hashes here.

File details

Details for the file web_framework_api-3.3.4-cp314-cp314-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.4-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6e81a0543050587c2d7acde694ae2b15af56a0c8f971571ba21faaa3f64815d7
MD5 cb7b4609c4b2ca14a03a5a534df10c36
BLAKE2b-256 253a2c00a345d27523b5002900dc46e8c4a30fed98e3f8811d18d98687ec0311

See more details on using hashes here.

File details

Details for the file web_framework_api-3.3.4-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 743538dcf3a6e66804401bf1592974a77ee10617c1c1bbc285c8ac40d6eaf5a6
MD5 67b3138d2de6928ae8b452e83106c748
BLAKE2b-256 97d46173e9b36068e12bdeb0526b15f2e24e7927b5d811331fc624eeed37d110

See more details on using hashes here.

File details

Details for the file web_framework_api-3.3.4-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.4-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0ee6ae4bcfdb6d54c25efb90b3481e41449b38e9543b03f2a87898a10d5b23e9
MD5 b82f6f8c37d7f34e802a685a58ce9a2e
BLAKE2b-256 04a7e6b765055d7d395536a6b85a1bdfa14756ffaf4a7553ac400cbc4c22499c

See more details on using hashes here.

File details

Details for the file web_framework_api-3.3.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 104c9b362c82dae7edba25ca83e126855638b4a5d46a7b358e4f472b7aeef93b
MD5 1a46ba615502ea7aa1b981f4dce5f946
BLAKE2b-256 686a3619459b4c25250fed80b2158c02d3e384d67bd6e03ee7f689ccd7af5d9d

See more details on using hashes here.

File details

Details for the file web_framework_api-3.3.4-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.4-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3d9a84b9b69a437ba5791ee1115dbdec4108bbec6fbfb5f8bc84659d5121663b
MD5 825facee1874167f3aa57c78f06317c8
BLAKE2b-256 e58d006c5740c1f986032f36ba52cd475706afb0a24e38ceb2c97ffc87626e57

See more details on using hashes here.

Supported by

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