web-framework-api


Nameweb-framework-api JSON
Version 1.0.5 PyPI version JSON
download
home_pageNone
SummaryPython API for WebFramework
upload_time2024-11-16 06:30:45
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/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/0a/5c/1e7fce38f017fd7071d6eec95448a9127b3170d6e5f17671e20101bef2f2/web_framework_api-1.0.5.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.5",
    "project_urls": {
        "Repository": "http://github.com/LazyPanda07/WebFramework",
        "Wiki": "http://github.com/LazyPanda07/WebFramework/wiki"
    },
    "split_keywords": [
        "web"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d293d4f124742cf6b5a83077cbdd4194735694c9e546f057959e2e58a3c2b340",
                "md5": "4b2d5ffa85bda4857b901a907fa94a84",
                "sha256": "e237459fb172efd606a3af489ceaf2b10a0d23c233d909e5507d36887528e44e"
            },
            "downloads": -1,
            "filename": "web_framework_api-1.0.5-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4b2d5ffa85bda4857b901a907fa94a84",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 7820,
            "upload_time": "2024-11-16T06:30:44",
            "upload_time_iso_8601": "2024-11-16T06:30:44.201826Z",
            "url": "https://files.pythonhosted.org/packages/d2/93/d4f124742cf6b5a83077cbdd4194735694c9e546f057959e2e58a3c2b340/web_framework_api-1.0.5-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a5c1e7fce38f017fd7071d6eec95448a9127b3170d6e5f17671e20101bef2f2",
                "md5": "5432fcd507c8af5b56bc231a4b47c404",
                "sha256": "cf1fd6e7a9c4666566eef8a84f39f9823147d211829c9dd607ace7173cdd9380"
            },
            "downloads": -1,
            "filename": "web_framework_api-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "5432fcd507c8af5b56bc231a4b47c404",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5271,
            "upload_time": "2024-11-16T06:30:45",
            "upload_time_iso_8601": "2024-11-16T06:30:45.687173Z",
            "url": "https://files.pythonhosted.org/packages/0a/5c/1e7fce38f017fd7071d6eec95448a9127b3170d6e5f17671e20101bef2f2/web_framework_api-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-16 06:30:45",
    "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: 1.52875s