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

Uploaded CPython 3.14Windows x86-64

web_framework_api-3.3.6-cp314-cp314-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.13Windows x86-64

web_framework_api-3.3.6-cp313-cp313-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

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

Uploaded CPython 3.12Windows x86-64

web_framework_api-3.3.6-cp312-cp312-manylinux_2_34_x86_64.whl (14.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1eafe9d4afa8cd64a8bf29a9d5041863022d5bd86e3d0dd67522f34ff80c30b7
MD5 ed54c3e1fd9caf141099f496fdae1343
BLAKE2b-256 bdcf5dfa771949cdc312320c778e3ad1289493ccd45278b711429bfd090bafee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.6-cp314-cp314-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8ada32df517705c18b67c2200cf7d26bd3065a3b68876a283b37d5d402135e0a
MD5 3fb8fc172a8c61aaa1ff83955f838ab8
BLAKE2b-256 b912b619cf276322d326b0497c9ce5d3cc77a65e35b15115969f04e775af7dde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 36b750ab31e55d6b457313373a1e2af7f48c39951d44653ba1449a8c5fc97e72
MD5 c1c23977ec7323f1b70d01425f75ec74
BLAKE2b-256 aae08645bf4d209a1955251a1cfd10e9cb9513a1bf946acc2c022ee87e911fce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.6-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f8d67a4d02b6aa9175e5e7cf5814e1d74128b46c01c4286671f78ca538867e1f
MD5 7516ec673edc44d61d4caa1cb3df7f9f
BLAKE2b-256 ab44cf7aaa95a1ea1fa35b27a243188143564fc9281079352f514c8368dc436c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 03ae98b1024b6652152452ea269e46573feb417fbf4cd5434f9b129f629e8911
MD5 30bbf5a837a1a3a1ac30e68761bafd9c
BLAKE2b-256 bcd0759d83aa898e075493712ba1d69965002e3e29c48b15c462053d534fcb74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for web_framework_api-3.3.6-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 eec68b4c1fd350e8c4a82a7a04399b64a509c13c40681baa5a69d36b011eac2d
MD5 e544bac0121c8d26941f87558fb011d7
BLAKE2b-256 056ec75b0218f25bc29bcf5a7f282f4b1e863d5c0917d87af1146053f1842e0f

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