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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

web_framework_api-3.3.5-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.5-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 93756b70114c90528e729612d72ab99988df3e13991831d8034d326091af730e
MD5 e9ea20ad81646f126644042fdf9601e2
BLAKE2b-256 f6d485068f61d10f6ecf160f30a25d40cf1a16fea8cba0a49553085b13b312c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.5-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d78368e463cd36f2f976c7854a976afc9380b0d9b70f456791a255906d67f8dd
MD5 77fa1c6e84e4e4f7d128f4e29695a534
BLAKE2b-256 0e6de1ef4505a66c1a41c9cbf12c36ddad4fdff1c799f359bcbc66049d6855f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3b59a7ad71a38ec269bfff0abe99952f1f4c83b67c6d044f92fd7cd3694bb481
MD5 93926d2344d408aea37b2f8f2ea67d15
BLAKE2b-256 08d345e2856f24fef7f449b1eeb9709beb4743fb162bba85d9d81e0672304b1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.5-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7b68569bbdf51c51566ae147ff331a4b6b611def828abc30d971a971e957be60
MD5 b28cfa73831f5e3466c1f12e3f2b009a
BLAKE2b-256 a77049665a417252174a502a6175a0a7901dc7ae8d0802b5ba61f2664fc5e39b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ba957be54de1e73b4b6de5821bf048789f35a231f75a68522c844b634cde3056
MD5 589f09250364cc0d37f683d92b3802f1
BLAKE2b-256 842dea4e5931bdc62d50acf1447e329f1371a8ad124f0f632cda28c3f053e779

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 63550976c6a4c0de89d6332b07fc70c9a721c3920f6a5f213b762ae4340861fb
MD5 cfaf6a899e66263110c9c022a010ee8c
BLAKE2b-256 3e2ad1653826066a513c99c71e4e7159509f8a9bd14ce6985d4239c82a7b10dd

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