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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: web_framework_api
3
- Version: 1.0.5
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/Assets/windows.zip)
32
- * [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/linux.zip)
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/Assets/windows.zip)
165
- * [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/linux.zip)
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/Assets/windows.zip)
17
- * [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/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/download/Assets/windows.zip)
150
- * [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/linux.zip)
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)
@@ -13,7 +13,7 @@ maintainers = [
13
13
  { name = "LazyPanda07", email = "semengricenko@gmail.com" }
14
14
  ]
15
15
  keywords = ["Web"]
16
- version = "1.0.5"
16
+ version = "1.0.7"
17
17
  dependencies = [
18
18
  "multipledispatch",
19
19
  "requests",
@@ -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
 
@@ -8,7 +8,7 @@ import requests
8
8
  from tqdm import tqdm
9
9
 
10
10
  WEB_FRAMEWORK_MAJOR_VERSION = "0"
11
- WEB_FRAMEWORK_MINOR_VERSION = "10"
11
+ WEB_FRAMEWORK_MINOR_VERSION = "12"
12
12
  WEB_FRAMEWORK_LIBRARIES_FILE_NAME = "libraries.zip"
13
13
  WEB_FRAMEWORK_DOWNLOAD_BLOCK_SIZE = 1024
14
14