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.3-cp314-cp314-win_amd64.whl (6.3 MB view details)

Uploaded CPython 3.14Windows x86-64

web_framework_api-3.3.3-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.3-cp313-cp313-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.13Windows x86-64

web_framework_api-3.3.3-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.3-cp312-cp312-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.12Windows x86-64

web_framework_api-3.3.3-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.3-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 6282873bbc6ecbb654f3a21956fdc6576cad40ee3e766707c9d0e1849bfb42af
MD5 0294c7ab3e132f36a6d9bf2135840bd3
BLAKE2b-256 c91d0cacab81fd7dd8b5bf848e32380bd85a0e6774de1712ec7dc6eb1781a3db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.3-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 485be9706f6e00acd09533171f69cf782e9b240c131ea378fcab986870b9b0ee
MD5 b1ef59f8bbefddf2c492542444ffc8d6
BLAKE2b-256 2a946e17ce737dedca0339cda7dcbf0e682ca7368933f8af98e59c8da1b09392

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 557c58335e9e189a4c2731dd3d0fe69b4576a4d54d1b7ab8c2b6b6bddbf1016a
MD5 a66760e9d752e54924f7c973c494eb87
BLAKE2b-256 33fdaa6a2b631d4cece3e96e587eea03910f8be41937c02618f6b95ddee878ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.3-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ee08f3bfba4c6dce599df1501ba11393480678c6481cafb33479fe330807f180
MD5 2dec3574cfc099a47d5b99bbc5235318
BLAKE2b-256 865f22ad405d67aa8b0cfd5ce3850d8810e33da152345943ad644d53a30dd0bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 49fc49db86d20ced0a1ce9d6f3388ee5bb9d020c494379e6259f8a71c57aa055
MD5 120e2abee4fea5b383325083a79a26eb
BLAKE2b-256 9632d4685d18894a2ea1f50662e97e3f9c4bb3a76447cf954b87329d649139a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f05eeebbc99eea3dae03bd38a66f740aa6f05afbc9bfcb56c01eca45c8d1485a
MD5 5c0793f0e484f72de451337690f526ab
BLAKE2b-256 971d8dd58e6a16ab136b3968ef06ab3a57dee5e041db535952b2f18f2df7bce7

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