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

Uploaded CPython 3.14Windows x86-64

web_framework_api-3.3.1-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.1-cp313-cp313-win_amd64.whl (4.7 MB view details)

Uploaded CPython 3.13Windows x86-64

web_framework_api-3.3.1-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.1-cp312-cp312-win_amd64.whl (4.7 MB view details)

Uploaded CPython 3.12Windows x86-64

web_framework_api-3.3.1-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.1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 eae861b1db89ccae43b713548df4de90ab722f8b086baee8abcb977519d3bd5a
MD5 a9dd081a7122bc071a3f05af21333e2f
BLAKE2b-256 1a1c558544b7b9d56a34dff955886ff4b924a5ecb24c04050cafe5a3e6dc14a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.1-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8ae878cd0a19e10438676d396c9f98594f9da377df860af3ec1d37f07182bab2
MD5 c911bcad784a25dd2704fbc1b18039b0
BLAKE2b-256 dbfa5aa42bd9a8f191fb63d2a6265a8149d326cc3aa702c951947358ae98f285

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 328bdbc8fe25d9189dbe635b514cfbc6f5633fbc243cea6d5accaf134ced2850
MD5 8d4e16dca2df09b63d72913c6f392e38
BLAKE2b-256 3bb0c2901c92257563009119426a60645b1c35b50695a736cb8726b0a08976ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.1-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 95193382ae7b7e1c6847f364b0321c04bf6748de28e1f0720a72d22d5b4b39a7
MD5 44cc46c2d754c48b070be87af6011b99
BLAKE2b-256 a49fc7b215beaa32a2ed0e145547252ee4a990e6695e2be1ec10aff9895832f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c890b10af37eaa8f7d7d850d2fe57fd4636f8974091a073f33ebffc49f9a1392
MD5 9c930c308b77f039da04b222188b7e69
BLAKE2b-256 08405e74b53d272d650384d6b986d8101b69a1f8f26d78c1b246ad6d98aa561f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a32c46f3f64b8e22842e932a8b954e416264df6d2a103d522e25247db4779172
MD5 985ea70fbcdfa42349a73b365a7def51
BLAKE2b-256 f03fd649d9fb96488c9b726400bd5ba0c14037ce145aba2040a197bbf5fbb6ce

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