web-framework-api 1.0.5__tar.gz → 1.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {web_framework_api-1.0.5 → web_framework_api-1.0.7}/PKG-INFO +6 -6
- {web_framework_api-1.0.5 → web_framework_api-1.0.7}/README.md +150 -150
- {web_framework_api-1.0.5 → web_framework_api-1.0.7}/pyproject.toml +1 -1
- {web_framework_api-1.0.5 → web_framework_api-1.0.7}/web_framework_api/WebFramework.py +10 -0
- {web_framework_api-1.0.5 → web_framework_api-1.0.7}/web_framework_api/utility/DLLHandler.py +1 -1
- {web_framework_api-1.0.5 → web_framework_api-1.0.7}/web_framework_api/utility/Utils.py +1 -1
- {web_framework_api-1.0.5 → web_framework_api-1.0.7}/web_framework_api/__init__.py +0 -0
- {web_framework_api-1.0.5 → web_framework_api-1.0.7}/web_framework_api/exceptions/WebFrameworkException.py +0 -0
- {web_framework_api-1.0.5 → web_framework_api-1.0.7}/web_framework_api/utility/Config.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: web_framework_api
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: Python API for WebFramework
|
|
5
5
|
Project-URL: Repository, http://github.com/LazyPanda07/WebFramework
|
|
6
6
|
Project-URL: Wiki, http://github.com/LazyPanda07/WebFramework/wiki
|
|
@@ -28,8 +28,8 @@ C++ HTTP/HTTPS server with Python API
|
|
|
28
28
|
Server needs few files to run:
|
|
29
29
|
* [web.json](#settings) with routes
|
|
30
30
|
* [Executors](#executors)
|
|
31
|
-
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/download/
|
|
32
|
-
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/
|
|
31
|
+
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_windows.zip)
|
|
32
|
+
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_linux.zip)
|
|
33
33
|
* [config.json](#config) with server settings
|
|
34
34
|
All these files must be in the same directory as ```main.py```
|
|
35
35
|
|
|
@@ -161,5 +161,5 @@ More information you can find in [wiki](https://github.com/LazyPanda07/WebFramew
|
|
|
161
161
|
|
|
162
162
|
### Hello executor
|
|
163
163
|
* Links
|
|
164
|
-
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/download/
|
|
165
|
-
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/
|
|
164
|
+
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_windows.zip)
|
|
165
|
+
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_linux.zip)
|
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
C++ HTTP/HTTPS server with Python API
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* [Quick start](#quick-start)
|
|
5
|
-
* [main.py](#mainpy)
|
|
6
|
-
* [Settings](#settings)
|
|
7
|
-
* [Config](#config)
|
|
8
|
-
* [Run sample](#run-sample)
|
|
9
|
-
* [Executors](#executors)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## Quick start
|
|
13
|
-
Server needs few files to run:
|
|
14
|
-
* [web.json](#settings) with routes
|
|
15
|
-
* [Executors](#executors)
|
|
16
|
-
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/download/
|
|
17
|
-
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/
|
|
18
|
-
* [config.json](#config) with server settings
|
|
19
|
-
All these files must be in the same directory as ```main.py```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### main.py
|
|
23
|
-
```python
|
|
24
|
-
from web_framework_api.WebFramework import WebFramework # Server
|
|
25
|
-
from web_framework_api.utility.DLLHandler import initialize_web_framework # WebFramework initialization
|
|
26
|
-
from web_framework_api.exceptions.WebFrameworkException import WebFrameworkException # Exception
|
|
27
|
-
|
|
28
|
-
def on_start():
|
|
29
|
-
print("Server is running")
|
|
30
|
-
|
|
31
|
-
if __name__ == '__main__':
|
|
32
|
-
try:
|
|
33
|
-
initialize_web_framework() # Load WebFramework shared library
|
|
34
|
-
|
|
35
|
-
server = WebFramework.from_path("config.json") # Create server
|
|
36
|
-
|
|
37
|
-
server.start(True, on_start) # Start server and wait
|
|
38
|
-
except WebFrameworkException as exception:
|
|
39
|
-
print(exception)
|
|
40
|
-
|
|
41
|
-
exit(-1)
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### Settings
|
|
46
|
-
```web.json```
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"HelloExecutor": {
|
|
50
|
-
"route": "",
|
|
51
|
-
"loadType": "initialization"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### Config
|
|
58
|
-
```config.json```
|
|
59
|
-
```json
|
|
60
|
-
{
|
|
61
|
-
"WebServer": {
|
|
62
|
-
"ip": "0.0.0.0",
|
|
63
|
-
"port": 8080,
|
|
64
|
-
"timeout": 0
|
|
65
|
-
},
|
|
66
|
-
"WebFramework": {
|
|
67
|
-
"settingsPaths": [
|
|
68
|
-
"web.json"
|
|
69
|
-
],
|
|
70
|
-
"loadSources": [
|
|
71
|
-
"hello_executor"
|
|
72
|
-
],
|
|
73
|
-
"assetsPath": "assets",
|
|
74
|
-
"templatesPath": "templates",
|
|
75
|
-
"cachingSize": 536870912,
|
|
76
|
-
"webServerType": "multiThreaded",
|
|
77
|
-
"HTTPS": {
|
|
78
|
-
"useHTTPS": false,
|
|
79
|
-
"pathToCertificate": "certificates/cert.pem",
|
|
80
|
-
"pathToKey": "certificates/key.pem"
|
|
81
|
-
},
|
|
82
|
-
"defaultAssetsPath": "WebFrameworkAssets"
|
|
83
|
-
},
|
|
84
|
-
"Logging": {
|
|
85
|
-
"usingLogging": false,
|
|
86
|
-
"dateFormat": "DMY",
|
|
87
|
-
"logFileSize": 134217728
|
|
88
|
-
},
|
|
89
|
-
"ThreadPoolServer": {
|
|
90
|
-
"threadCount": 0
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
### Run sample
|
|
97
|
-
After running server open url [127.0.0.1:8080](http://127.0.0.1:8080).
|
|
98
|
-
You will see response from server
|
|
99
|
-
```json
|
|
100
|
-
{
|
|
101
|
-
"message": "Hello, World!"
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
## Executors
|
|
107
|
-
Executors are C++ classes that responsible for giving responses for their route(url).
|
|
108
|
-
Source code of HelloExecutor from example
|
|
109
|
-
```HelloExecutor.h```
|
|
110
|
-
```cpp
|
|
111
|
-
#pragma once
|
|
112
|
-
|
|
113
|
-
#include "Executors/BaseStatelessExecutor.h"
|
|
114
|
-
|
|
115
|
-
namespace executors
|
|
116
|
-
{
|
|
117
|
-
class HelloExecutor : public framework::BaseStatelessExecutor
|
|
118
|
-
{
|
|
119
|
-
public:
|
|
120
|
-
HelloExecutor() = default;
|
|
121
|
-
|
|
122
|
-
void doGet(framework::HTTPRequest& request, framework::HTTPResponse& response) override;
|
|
123
|
-
|
|
124
|
-
~HelloExecutor() = default;
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
```HelloExecutor.cpp```
|
|
129
|
-
```cpp
|
|
130
|
-
#include "HelloExecutor.h"
|
|
131
|
-
|
|
132
|
-
#include "JSONBuilder.h"
|
|
133
|
-
|
|
134
|
-
namespace executors
|
|
135
|
-
{
|
|
136
|
-
void HelloExecutor::doGet(framework::HTTPRequest& request, framework::HTTPResponse& response)
|
|
137
|
-
{
|
|
138
|
-
response.addBody(json::JSONBuilder(CP_UTF8).appendString("message", "Hello, World!"));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
DECLARE_EXECUTOR(HelloExecutor);
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
More information you can find in [wiki](https://github.com/LazyPanda07/WebFramework/wiki/Executors).
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
### Hello executor
|
|
148
|
-
* Links
|
|
149
|
-
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/download/
|
|
150
|
-
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/
|
|
1
|
+
C++ HTTP/HTTPS server with Python API
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
* [Quick start](#quick-start)
|
|
5
|
+
* [main.py](#mainpy)
|
|
6
|
+
* [Settings](#settings)
|
|
7
|
+
* [Config](#config)
|
|
8
|
+
* [Run sample](#run-sample)
|
|
9
|
+
* [Executors](#executors)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
Server needs few files to run:
|
|
14
|
+
* [web.json](#settings) with routes
|
|
15
|
+
* [Executors](#executors)
|
|
16
|
+
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_windows.zip)
|
|
17
|
+
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_linux.zip)
|
|
18
|
+
* [config.json](#config) with server settings
|
|
19
|
+
All these files must be in the same directory as ```main.py```
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### main.py
|
|
23
|
+
```python
|
|
24
|
+
from web_framework_api.WebFramework import WebFramework # Server
|
|
25
|
+
from web_framework_api.utility.DLLHandler import initialize_web_framework # WebFramework initialization
|
|
26
|
+
from web_framework_api.exceptions.WebFrameworkException import WebFrameworkException # Exception
|
|
27
|
+
|
|
28
|
+
def on_start():
|
|
29
|
+
print("Server is running")
|
|
30
|
+
|
|
31
|
+
if __name__ == '__main__':
|
|
32
|
+
try:
|
|
33
|
+
initialize_web_framework() # Load WebFramework shared library
|
|
34
|
+
|
|
35
|
+
server = WebFramework.from_path("config.json") # Create server
|
|
36
|
+
|
|
37
|
+
server.start(True, on_start) # Start server and wait
|
|
38
|
+
except WebFrameworkException as exception:
|
|
39
|
+
print(exception)
|
|
40
|
+
|
|
41
|
+
exit(-1)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Settings
|
|
46
|
+
```web.json```
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"HelloExecutor": {
|
|
50
|
+
"route": "",
|
|
51
|
+
"loadType": "initialization"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Config
|
|
58
|
+
```config.json```
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"WebServer": {
|
|
62
|
+
"ip": "0.0.0.0",
|
|
63
|
+
"port": 8080,
|
|
64
|
+
"timeout": 0
|
|
65
|
+
},
|
|
66
|
+
"WebFramework": {
|
|
67
|
+
"settingsPaths": [
|
|
68
|
+
"web.json"
|
|
69
|
+
],
|
|
70
|
+
"loadSources": [
|
|
71
|
+
"hello_executor"
|
|
72
|
+
],
|
|
73
|
+
"assetsPath": "assets",
|
|
74
|
+
"templatesPath": "templates",
|
|
75
|
+
"cachingSize": 536870912,
|
|
76
|
+
"webServerType": "multiThreaded",
|
|
77
|
+
"HTTPS": {
|
|
78
|
+
"useHTTPS": false,
|
|
79
|
+
"pathToCertificate": "certificates/cert.pem",
|
|
80
|
+
"pathToKey": "certificates/key.pem"
|
|
81
|
+
},
|
|
82
|
+
"defaultAssetsPath": "WebFrameworkAssets"
|
|
83
|
+
},
|
|
84
|
+
"Logging": {
|
|
85
|
+
"usingLogging": false,
|
|
86
|
+
"dateFormat": "DMY",
|
|
87
|
+
"logFileSize": 134217728
|
|
88
|
+
},
|
|
89
|
+
"ThreadPoolServer": {
|
|
90
|
+
"threadCount": 0
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Run sample
|
|
97
|
+
After running server open url [127.0.0.1:8080](http://127.0.0.1:8080).
|
|
98
|
+
You will see response from server
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"message": "Hello, World!"
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## Executors
|
|
107
|
+
Executors are C++ classes that responsible for giving responses for their route(url).
|
|
108
|
+
Source code of HelloExecutor from example
|
|
109
|
+
```HelloExecutor.h```
|
|
110
|
+
```cpp
|
|
111
|
+
#pragma once
|
|
112
|
+
|
|
113
|
+
#include "Executors/BaseStatelessExecutor.h"
|
|
114
|
+
|
|
115
|
+
namespace executors
|
|
116
|
+
{
|
|
117
|
+
class HelloExecutor : public framework::BaseStatelessExecutor
|
|
118
|
+
{
|
|
119
|
+
public:
|
|
120
|
+
HelloExecutor() = default;
|
|
121
|
+
|
|
122
|
+
void doGet(framework::HTTPRequest& request, framework::HTTPResponse& response) override;
|
|
123
|
+
|
|
124
|
+
~HelloExecutor() = default;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
```HelloExecutor.cpp```
|
|
129
|
+
```cpp
|
|
130
|
+
#include "HelloExecutor.h"
|
|
131
|
+
|
|
132
|
+
#include "JSONBuilder.h"
|
|
133
|
+
|
|
134
|
+
namespace executors
|
|
135
|
+
{
|
|
136
|
+
void HelloExecutor::doGet(framework::HTTPRequest& request, framework::HTTPResponse& response)
|
|
137
|
+
{
|
|
138
|
+
response.addBody(json::JSONBuilder(CP_UTF8).appendString("message", "Hello, World!"));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
DECLARE_EXECUTOR(HelloExecutor);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
More information you can find in [wiki](https://github.com/LazyPanda07/WebFramework/wiki/Executors).
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
### Hello executor
|
|
148
|
+
* Links
|
|
149
|
+
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_windows.zip)
|
|
150
|
+
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_linux.zip)
|
|
@@ -12,6 +12,16 @@ class WebFramework:
|
|
|
12
12
|
Web server
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
+
@staticmethod
|
|
16
|
+
def get_web_framework_version() -> str:
|
|
17
|
+
"""
|
|
18
|
+
Get WebFramework version
|
|
19
|
+
:return: String representation of version in format {major}.{minor}.{patch}
|
|
20
|
+
"""
|
|
21
|
+
version = DLLHandler.get_instance().call_function("getWebFrameworkVersion", ctypes.c_char_p)
|
|
22
|
+
|
|
23
|
+
return str(version.decode())
|
|
24
|
+
|
|
15
25
|
def __init__(self, implementation: ctypes.c_void_p):
|
|
16
26
|
self.__implementation = implementation
|
|
17
27
|
self.__function_signature = ctypes.CFUNCTYPE(None)
|
|
@@ -55,7 +55,7 @@ class DLLHandler:
|
|
|
55
55
|
self.__handle = ctypes.CDLL(path_to_dll)
|
|
56
56
|
|
|
57
57
|
@classmethod
|
|
58
|
-
def get_instance(cls):
|
|
58
|
+
def get_instance(cls) -> "DLLHandler":
|
|
59
59
|
if cls.instance is None:
|
|
60
60
|
raise Exception("WebFramework must be initialized with initialize_web_framework function")
|
|
61
61
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|