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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.12Windows x86-64

web_framework_api-3.3.2-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.2-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.3.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0e8c759b6e174e48b0392a1eeb89279a2ed9017175f6fe0419d4bf89786f1fda
MD5 4a11ffd92967a9068ddef3b2947a1a54
BLAKE2b-256 a5577d33a6f297d41e0493becd2303aa6a77dd729de3dc5228714f7c5c912ba4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.2-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ac422de3213660714fd448044adbc4de7faddf9fa684f48adbf6a2e6e1a23ee3
MD5 d4e66cf1bf1133ef300bca274d3d28ab
BLAKE2b-256 c0f0b78278f72df4821888d0a9ddc270f279409c7f3efb370d3f67d248325848

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 addde2b17f3f8919f7d6d3ad3aa2f20bf2ba105afe0f6cbb715603d9c98b4545
MD5 298c42089726e666e6595ecbda66f607
BLAKE2b-256 b1ff8b02fe4e097fff647a212f2d674edcf0b4390a641a13e7a399a5593629ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.2-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 882b0d615d9e2b22c7e95d10b74cabd95d42f9a5ed4875b7d5a8a7675092d6e0
MD5 84345f3f5a86febc01a71059e935c90a
BLAKE2b-256 885d4042a55eca834c211d142d70e0f6d160edac9b128567c06a1428a1a89d8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 07584a90c78675821b43ec4978a06d57c4e47bedf2034f0148a0eec75fc5a46d
MD5 01c04a8946849f448f70e246996c2950
BLAKE2b-256 f055eab0e41c0d6286e7195bd8de4e325f13f327ea5a63bb37a8de15144eee3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.2-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ff4475ab916bc8a6337a53846d02a455461468cc09bb56fe27be5c5b466da846
MD5 58122a2b6a95cad47f8c7f748178e6a0
BLAKE2b-256 254bd662a91a7cccd0cca7e771ae932b7fc31fa26a12d9b1f060ab73e1aef30d

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