diff --git a/README.md b/README.md index 3e40291..b7d42ff 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ Fast WebSocket and Http/Https server using CFFI with C API from [uNetworking/uWe This project aims at High Performance PyPy3 Web Development and WebSockets -> This project will adapt the full capi from uNetworking/uWebSockets but for now it's just this. +> This project will adapt the full C API from uNetworking/uWebSockets, this same C API is used by [Bun](https://bun.sh/) -### Overly simple hello world app +### Overly simple hello world app [click here](https://github.com/cirospaciari/socketify.py/tree/main/examples) for more examples ```python from socketify import App @@ -15,6 +15,7 @@ app.listen(3000, lambda config: print("Listening on port http://localhost:%d now app.run() ``` + ### pip install ```bash diff --git a/tests/examples/async.py b/examples/async.py similarity index 100% rename from tests/examples/async.py rename to examples/async.py diff --git a/tests/examples/automatic_port_selection.py b/examples/automatic_port_selection.py similarity index 100% rename from tests/examples/automatic_port_selection.py rename to examples/automatic_port_selection.py diff --git a/tests/examples/docker/pypy3/Dockerfile b/examples/docker/pypy3/Dockerfile similarity index 100% rename from tests/examples/docker/pypy3/Dockerfile rename to examples/docker/pypy3/Dockerfile diff --git a/tests/examples/docker/pypy3/main.py b/examples/docker/pypy3/main.py similarity index 100% rename from tests/examples/docker/pypy3/main.py rename to examples/docker/pypy3/main.py diff --git a/tests/examples/docker/pypy3/requirements.txt b/examples/docker/pypy3/requirements.txt similarity index 100% rename from tests/examples/docker/pypy3/requirements.txt rename to examples/docker/pypy3/requirements.txt diff --git a/tests/examples/docker/python3-alpine/Dockerfile b/examples/docker/python3-alpine/Dockerfile similarity index 100% rename from tests/examples/docker/python3-alpine/Dockerfile rename to examples/docker/python3-alpine/Dockerfile diff --git a/tests/examples/docker/python3-alpine/main.py b/examples/docker/python3-alpine/main.py similarity index 100% rename from tests/examples/docker/python3-alpine/main.py rename to examples/docker/python3-alpine/main.py diff --git a/tests/examples/docker/python3-alpine/requirements.txt b/examples/docker/python3-alpine/requirements.txt similarity index 100% rename from tests/examples/docker/python3-alpine/requirements.txt rename to examples/docker/python3-alpine/requirements.txt diff --git a/tests/examples/docker/python3/Dockerfile b/examples/docker/python3/Dockerfile similarity index 100% rename from tests/examples/docker/python3/Dockerfile rename to examples/docker/python3/Dockerfile diff --git a/tests/examples/docker/python3/main.py b/examples/docker/python3/main.py similarity index 100% rename from tests/examples/docker/python3/main.py rename to examples/docker/python3/main.py diff --git a/tests/examples/docker/python3/requirements.txt b/examples/docker/python3/requirements.txt similarity index 100% rename from tests/examples/docker/python3/requirements.txt rename to examples/docker/python3/requirements.txt diff --git a/tests/examples/error_handler.py b/examples/error_handler.py similarity index 100% rename from tests/examples/error_handler.py rename to examples/error_handler.py diff --git a/tests/examples/file_stream.py b/examples/file_stream.py similarity index 100% rename from tests/examples/file_stream.py rename to examples/file_stream.py diff --git a/tests/examples/forks.py b/examples/forks.py similarity index 100% rename from tests/examples/forks.py rename to examples/forks.py diff --git a/tests/examples/graceful_shutdown.py b/examples/graceful_shutdown.py similarity index 100% rename from tests/examples/graceful_shutdown.py rename to examples/graceful_shutdown.py diff --git a/tests/examples/hello_world.py b/examples/hello_world.py similarity index 100% rename from tests/examples/hello_world.py rename to examples/hello_world.py diff --git a/tests/examples/helpers/memory_cache.py b/examples/helpers/memory_cache.py similarity index 100% rename from tests/examples/helpers/memory_cache.py rename to examples/helpers/memory_cache.py diff --git a/tests/examples/helpers/static.py b/examples/helpers/static.py similarity index 100% rename from tests/examples/helpers/static.py rename to examples/helpers/static.py diff --git a/tests/examples/helpers/static_aiofile.py b/examples/helpers/static_aiofile.py similarity index 100% rename from tests/examples/helpers/static_aiofile.py rename to examples/helpers/static_aiofile.py diff --git a/tests/examples/helpers/static_aiofiles.py b/examples/helpers/static_aiofiles.py similarity index 100% rename from tests/examples/helpers/static_aiofiles.py rename to examples/helpers/static_aiofiles.py diff --git a/tests/examples/helpers/twolevel_cache.py b/examples/helpers/twolevel_cache.py similarity index 100% rename from tests/examples/helpers/twolevel_cache.py rename to examples/helpers/twolevel_cache.py diff --git a/tests/examples/http_request_cache.py b/examples/http_request_cache.py similarity index 100% rename from tests/examples/http_request_cache.py rename to examples/http_request_cache.py diff --git a/tests/examples/https.py b/examples/https.py similarity index 100% rename from tests/examples/https.py rename to examples/https.py diff --git a/tests/examples/listen_options.py b/examples/listen_options.py similarity index 100% rename from tests/examples/listen_options.py rename to examples/listen_options.py diff --git a/tests/examples/not_found.py b/examples/not_found.py similarity index 100% rename from tests/examples/not_found.py rename to examples/not_found.py diff --git a/tests/examples/public/css/main.css b/examples/public/css/main.css similarity index 100% rename from tests/examples/public/css/main.css rename to examples/public/css/main.css diff --git a/tests/examples/public/images/favicon.png b/examples/public/images/favicon.png similarity index 100% rename from tests/examples/public/images/favicon.png rename to examples/public/images/favicon.png diff --git a/tests/examples/public/index.html b/examples/public/index.html similarity index 100% rename from tests/examples/public/index.html rename to examples/public/index.html diff --git a/tests/examples/public/js/main.js b/examples/public/js/main.js similarity index 100% rename from tests/examples/public/js/main.js rename to examples/public/js/main.js diff --git a/tests/examples/public/media/flower.webm b/examples/public/media/flower.webm similarity index 100% rename from tests/examples/public/media/flower.webm rename to examples/public/media/flower.webm diff --git a/tests/examples/public/robots.txt b/examples/public/robots.txt similarity index 100% rename from tests/examples/public/robots.txt rename to examples/public/robots.txt diff --git a/tests/examples/requeriments.txt b/examples/requeriments.txt similarity index 100% rename from tests/examples/requeriments.txt rename to examples/requeriments.txt diff --git a/tests/examples/router_and_basics.py b/examples/router_and_basics.py similarity index 100% rename from tests/examples/router_and_basics.py rename to examples/router_and_basics.py diff --git a/tests/examples/static_files.py b/examples/static_files.py similarity index 100% rename from tests/examples/static_files.py rename to examples/static_files.py diff --git a/tests/examples/upload_or_post.py b/examples/upload_or_post.py similarity index 100% rename from tests/examples/upload_or_post.py rename to examples/upload_or_post.py diff --git a/tests/tests.py b/tests/tests.py deleted file mode 100644 index 3bdaf27..0000000 --- a/tests/tests.py +++ /dev/null @@ -1,52 +0,0 @@ -# https://github.com/Tinche/aiofiles -# https://github.com/uNetworking/uWebSockets/issues/1426 - -# import os.path - -# def in_directory(file, directory): -# #make both absolute -# directory = os.path.join(os.path.realpath(directory), '') -# file = os.path.realpath(file) - -# #return true, if the common prefix of both is equal to directory -# #e.g. /a/b/c/d.rst and directory is /a/b, the common prefix is /a/b -# return os.path.commonprefix([file, directory]) == directory - -# application/x-www-form-urlencoded -# application/x-www-form-urlencoded -# multipart/form-data - - -# try_end -# for_each_header -# https://github.com/uNetworking/uWebSockets.js/blob/master/examples/VideoStreamer.js -from socketify import App -from datetime import datetime -from datetime import timedelta - -async def home(res, req): - data = await res.get_form_urlencoded() - print(data) - res.end(f"DATA! {data}") - -app = App() -app.post("/", home) -app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port)) -app.run() - -# from datetime import datetime -# raw = "_ga=GA1.1.1871393672.1649875681; affclick=null; __udf_j=d31b9af0d332fec181c1a893320322c0cb33ce95d7bdbd21a4cc4ee66d6d8c23817686b4ba59dd0e015cb95e8196157c" - -# jar = Cookies(None) -# jar.set("session_id", "123132", { -# "path": "/", -# "domain": "*.test.com", -# "httponly": True, -# "expires": datetime.now() -# }) -# print(jar.output()) -# jar = cookies.SimpleCookie(raw) -# print(jar["_gaasasd"]) -# print(split_header_words(raw)) - -#git submodule sync \ No newline at end of file