web-framework-api


Nameweb-framework-api JSON
Version 1.0.7 PyPI version JSON
download
home_pageNone
SummaryPython API for WebFramework
upload_time2024-12-29 11:38:46
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
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/latest/download/hello_executor_windows.zip)
	* [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_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/latest/download/hello_executor_windows.zip)
  * [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_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/d7/1c/0e89b19c40531b021adf9493ed58cb65ce3f35cb5e73d938826c1b2649aa/web_framework_api-1.0.7.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/latest/download/hello_executor_windows.zip)\n\t* [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_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/latest/download/hello_executor_windows.zip)\n  * [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_linux.zip)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python API for WebFramework",
    "version": "1.0.7",
    "project_urls": {
        "Repository": "http://github.com/LazyPanda07/WebFramework",
        "Wiki": "http://github.com/LazyPanda07/WebFramework/wiki"
    },
    "split_keywords": [
        "web"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "021881726f4ed9e1c27e6b53a1707445f510b1fda14a5a485c412885abfc118c",
                "md5": "eb4b991881f5e83f08f2fe4d900dd582",
                "sha256": "0129155f4c3df73bffb8967d3333abb11fce45567d42bfb839af00d70f7a0f12"
            },
            "downloads": -1,
            "filename": "web_framework_api-1.0.7-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "eb4b991881f5e83f08f2fe4d900dd582",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 7938,
            "upload_time": "2024-12-29T11:38:44",
            "upload_time_iso_8601": "2024-12-29T11:38:44.840138Z",
            "url": "https://files.pythonhosted.org/packages/02/18/81726f4ed9e1c27e6b53a1707445f510b1fda14a5a485c412885abfc118c/web_framework_api-1.0.7-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d71c0e89b19c40531b021adf9493ed58cb65ce3f35cb5e73d938826c1b2649aa",
                "md5": "8b0efcb0fb32cd3a2e39841cb54e7e1d",
                "sha256": "4536e4c65274775f364efb172e599e5cf0d90c4eeda1ae2ff1dcdd33b9feb3df"
            },
            "downloads": -1,
            "filename": "web_framework_api-1.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "8b0efcb0fb32cd3a2e39841cb54e7e1d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5678,
            "upload_time": "2024-12-29T11:38:46",
            "upload_time_iso_8601": "2024-12-29T11:38:46.927018Z",
            "url": "https://files.pythonhosted.org/packages/d7/1c/0e89b19c40531b021adf9493ed58cb65ce3f35cb5e73d938826c1b2649aa/web_framework_api-1.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-29 11:38:46",
    "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"
}
        
Elapsed time: 2.60763s