Name | web-framework-api JSON |
Version |
1.0.6
JSON |
| download |
home_page | None |
Summary | Python API for WebFramework |
upload_time | 2024-11-26 16:07:08 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | None |
keywords |
web
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
C++ HTTP/HTTPS server with Python API
* [Quick start](#quick-start)
* [main.py](#mainpy)
* [Settings](#settings)
* [Config](#config)
* [Run sample](#run-sample)
* [Executors](#executors)
## Quick start
Server needs few files to run:
* [web.json](#settings) with routes
* [Executors](#executors)
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/windows.zip)
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/linux.zip)
* [config.json](#config) with server settings
All these files must be in the same directory as ```main.py```
### main.py
```python
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```
```json
{
"HelloExecutor": {
"route": "",
"loadType": "initialization"
}
}
```
### Config
```config.json```
```json
{
"WebServer": {
"ip": "0.0.0.0",
"port": 8080,
"timeout": 0
},
"WebFramework": {
"settingsPaths": [
"web.json"
],
"loadSources": [
"hello_executor"
],
"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](http://127.0.0.1:8080).
You will see response from server
```json
{
"message": "Hello, World!"
}
```
## Executors
Executors are C++ classes that responsible for giving responses for their route(url).
Source code of HelloExecutor from example
```HelloExecutor.h```
```cpp
#pragma once
#include "Executors/BaseStatelessExecutor.h"
namespace executors
{
class HelloExecutor : public framework::BaseStatelessExecutor
{
public:
HelloExecutor() = default;
void doGet(framework::HTTPRequest& request, framework::HTTPResponse& response) override;
~HelloExecutor() = default;
};
}
```
```HelloExecutor.cpp```
```cpp
#include "HelloExecutor.h"
#include "JSONBuilder.h"
namespace executors
{
void HelloExecutor::doGet(framework::HTTPRequest& request, framework::HTTPResponse& response)
{
response.addBody(json::JSONBuilder(CP_UTF8).appendString("message", "Hello, World!"));
}
DECLARE_EXECUTOR(HelloExecutor);
}
```
More information you can find in [wiki](https://github.com/LazyPanda07/WebFramework/wiki/Executors).
### Hello executor
* Links
* [Windows](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/windows.zip)
* [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/linux.zip)
Raw data
{
"_id": null,
"home_page": null,
"name": "web-framework-api",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": "LazyPanda07 <semengricenko@gmail.com>",
"keywords": "Web",
"author": null,
"author_email": "LazyPanda07 <semengricenko@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/4b/13/225ecd501f6be10849775645419468b1235ccba45b83dd88e17b9d733441/web_framework_api-1.0.6.tar.gz",
"platform": null,
"description": "C++ HTTP/HTTPS server with Python API\n\n\n* [Quick start](#quick-start)\n * [main.py](#mainpy)\n * [Settings](#settings)\n * [Config](#config)\n * [Run sample](#run-sample)\n* [Executors](#executors)\n\n\n## Quick start\nServer needs few files to run: \n* [web.json](#settings) with routes\n* [Executors](#executors)\n\t* [Windows](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/windows.zip)\n\t* [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/linux.zip)\n* [config.json](#config) with server settings \nAll these files must be in the same directory as ```main.py```\n\n\n### main.py\n```python\nfrom web_framework_api.WebFramework import WebFramework # Server\nfrom web_framework_api.utility.DLLHandler import initialize_web_framework # WebFramework initialization \nfrom web_framework_api.exceptions.WebFrameworkException import WebFrameworkException # Exception\n\ndef on_start():\n print(\"Server is running\")\n\nif __name__ == '__main__':\n try:\n initialize_web_framework() # Load WebFramework shared library\n\n server = WebFramework.from_path(\"config.json\") # Create server\n\n server.start(True, on_start) # Start server and wait\n except WebFrameworkException as exception:\n print(exception)\n\n exit(-1)\n```\n\n\n### Settings\n```web.json```\n```json\n{\n \"HelloExecutor\": {\n \"route\": \"\",\n \"loadType\": \"initialization\"\n }\n}\n```\n\n\n### Config\n```config.json```\n```json\n{\n \"WebServer\": {\n \"ip\": \"0.0.0.0\",\n \"port\": 8080,\n \"timeout\": 0\n },\n \"WebFramework\": {\n \"settingsPaths\": [\n \"web.json\"\n ],\n \"loadSources\": [\n \"hello_executor\"\n ],\n \"assetsPath\": \"assets\",\n \"templatesPath\": \"templates\",\n \"cachingSize\": 536870912,\n \"webServerType\": \"multiThreaded\",\n \"HTTPS\": {\n \"useHTTPS\": false,\n \"pathToCertificate\": \"certificates/cert.pem\",\n \"pathToKey\": \"certificates/key.pem\"\n },\n \"defaultAssetsPath\": \"WebFrameworkAssets\"\n },\n \"Logging\": {\n \"usingLogging\": false,\n \"dateFormat\": \"DMY\",\n \"logFileSize\": 134217728\n },\n \"ThreadPoolServer\": {\n \"threadCount\": 0\n }\n}\n```\n\n\n### Run sample\nAfter running server open url [127.0.0.1:8080](http://127.0.0.1:8080). \nYou will see response from server\n```json\n{\n \"message\": \"Hello, World!\"\n}\n```\n\n\n## Executors\nExecutors are C++ classes that responsible for giving responses for their route(url). \nSource code of HelloExecutor from example \n```HelloExecutor.h```\n```cpp\n#pragma once\n\n#include \"Executors/BaseStatelessExecutor.h\"\n\nnamespace executors\n{\n\tclass HelloExecutor : public framework::BaseStatelessExecutor\n\t{\n\tpublic:\n\t\tHelloExecutor() = default;\n\n\t\tvoid doGet(framework::HTTPRequest& request, framework::HTTPResponse& response) override;\n\n\t\t~HelloExecutor() = default;\n\t};\n}\n```\n```HelloExecutor.cpp```\n```cpp\n#include \"HelloExecutor.h\"\n\n#include \"JSONBuilder.h\"\n\nnamespace executors\n{\n\tvoid HelloExecutor::doGet(framework::HTTPRequest& request, framework::HTTPResponse& response)\n\t{\n\t\tresponse.addBody(json::JSONBuilder(CP_UTF8).appendString(\"message\", \"Hello, World!\"));\n\t}\n\n\tDECLARE_EXECUTOR(HelloExecutor);\n}\n```\nMore information you can find in [wiki](https://github.com/LazyPanda07/WebFramework/wiki/Executors).\n\n\n### Hello executor\n* Links\n * [Windows](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/windows.zip)\n * [Linux](https://github.com/LazyPanda07/WebFramework/releases/download/Assets/linux.zip)\n",
"bugtrack_url": null,
"license": null,
"summary": "Python API for WebFramework",
"version": "1.0.6",
"project_urls": {
"Repository": "http://github.com/LazyPanda07/WebFramework",
"Wiki": "http://github.com/LazyPanda07/WebFramework/wiki"
},
"split_keywords": [
"web"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "807f37bf2655f2818b3fde5667dea689b9abe3dbd158a64164f95c31565c9552",
"md5": "be957f39eec58c4a00d808472fa84caa",
"sha256": "04d40e6ba6d271b41341ed44a7ecf6b2e4902c256919420ad1f3e74f3d7b36e7"
},
"downloads": -1,
"filename": "web_framework_api-1.0.6-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "be957f39eec58c4a00d808472fa84caa",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 7821,
"upload_time": "2024-11-26T16:07:06",
"upload_time_iso_8601": "2024-11-26T16:07:06.265974Z",
"url": "https://files.pythonhosted.org/packages/80/7f/37bf2655f2818b3fde5667dea689b9abe3dbd158a64164f95c31565c9552/web_framework_api-1.0.6-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4b13225ecd501f6be10849775645419468b1235ccba45b83dd88e17b9d733441",
"md5": "ee19e8f4363f57ac75157e3bef260699",
"sha256": "4006c7faf50e197b45fcc5457fbb63ac5c0d302e32a66dd289edd903afe0585e"
},
"downloads": -1,
"filename": "web_framework_api-1.0.6.tar.gz",
"has_sig": false,
"md5_digest": "ee19e8f4363f57ac75157e3bef260699",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5271,
"upload_time": "2024-11-26T16:07:08",
"upload_time_iso_8601": "2024-11-26T16:07:08.740526Z",
"url": "https://files.pythonhosted.org/packages/4b/13/225ecd501f6be10849775645419468b1235ccba45b83dd88e17b9d733441/web_framework_api-1.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 16:07:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LazyPanda07",
"github_project": "WebFramework",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "web-framework-api"
}