Python API for WebFramework
Project description
C++ HTTP/HTTPS server with Python API
Quick start
Server needs few files to run:
- web.json with routes
- Executors
- config.json with server settings
All these files must be in the same directory asmain.py
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file web_framework_api-3.3.7-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: web_framework_api-3.3.7-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 6.3 MB
- Tags: CPython 3.14, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39dff12ccfd68e4625be6e0f1d5bfe84c2778f065adc3a8460721a20d9d91ac3
|
|
| MD5 |
a5bca5482d22be32d71249a1ab2355ed
|
|
| BLAKE2b-256 |
4612a03e3c2dbef77b2f1c82627745cd59f91f5ddda7c71bf216c0cd1f7649fc
|
File details
Details for the file web_framework_api-3.3.7-cp314-cp314-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: web_framework_api-3.3.7-cp314-cp314-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 14.1 MB
- Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a395f53f2cbb542cacfe212bbbfebcca3eed8d4d8f5140b203691ff15260221
|
|
| MD5 |
e515b7550b9176740fe648df78785810
|
|
| BLAKE2b-256 |
637644110126eff56e2c5434f8934a49d844cac92cafce8f3b67157b37622789
|
File details
Details for the file web_framework_api-3.3.7-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: web_framework_api-3.3.7-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 6.1 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d420eaf07a29d5db0f950cc27d2d1a43088abcddd379f0c635462980b680c0d
|
|
| MD5 |
8b1284f6dc3196b3d6be5e52e2a30fdb
|
|
| BLAKE2b-256 |
71b7de11794d9958ad14c55990842ce44fa19a06139a2219fa5b2ab36424bf5b
|
File details
Details for the file web_framework_api-3.3.7-cp313-cp313-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: web_framework_api-3.3.7-cp313-cp313-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 14.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b44129332ba8771097dfacb5db04b6414fed24ae4bc1bd4fda7ce61b49a0c5b6
|
|
| MD5 |
c7649e64a5da462d3ad25640e9b1fd2b
|
|
| BLAKE2b-256 |
6c70553f5dc04f1fdcefb322a4f8cd4398af14036ac7b3d9cb7ad3e6f8f38aa8
|
File details
Details for the file web_framework_api-3.3.7-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: web_framework_api-3.3.7-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 6.1 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d907990b098f6224c09850a30ff274e5cb72ec196c2ce02dc9b8d8d54b655b4b
|
|
| MD5 |
3b31dba67f527718688e68449cab295f
|
|
| BLAKE2b-256 |
b1c79d11bc6461c44e710bafa7b46c25cc898d681ff80a2ef1dd673785bcb070
|
File details
Details for the file web_framework_api-3.3.7-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: web_framework_api-3.3.7-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 14.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9655874e03a1b3534f78b77c4165e93b6adbe49fa4dbb55e53c6bbbd9ad94630
|
|
| MD5 |
575244dfc48152e89e576d8d3669e194
|
|
| BLAKE2b-256 |
e986717ae16f0315408ee371cdbddd46032f98daa826a0b291cf5b79758cb648
|