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 Distribution

web_framework_api-3.2.0.tar.gz (4.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

web_framework_api-3.2.0-py3-none-win_amd64.whl (4.7 MB view details)

Uploaded Python 3Windows x86-64

File details

Details for the file web_framework_api-3.2.0.tar.gz.

File metadata

  • Download URL: web_framework_api-3.2.0.tar.gz
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for web_framework_api-3.2.0.tar.gz
Algorithm Hash digest
SHA256 38031caeee44d46085589fabc137c332dd0e3ad61f3380343fd7aa2d75219bab
MD5 7beb0e2999910ea41a816de57451cfee
BLAKE2b-256 356786838bbb82af1134d4efac79529c2d319081cc83142a574ccf0bf5a98b56

See more details on using hashes here.

File details

Details for the file web_framework_api-3.2.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for web_framework_api-3.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e33b4164219fef55f2edb97b7029340699510fe6ad898d36b4d76a5d9eb23652
MD5 98807a4f814e6d51986d15ba261820ec
BLAKE2b-256 36f9df56c77ed4e2a5bd1067a0c5d1657814a7f321d6755853330432d9048b90

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