This release is made up of a few major changes:
- We have now updated to pyo3 0.14
- We can now serve static directories(i.e. host a react project)
- A request object is now available to PUT, POST and PATCH
- You can now add body in PUT, PATCH and DELETE
- We have a hot reloading server now looking for changes in directory
- We are now using actix as a base
Special Thanks to:
- @JackThomson2 for improving the speed of the server and the actix integration
- @awestlake87 for the upgrade of
pyo3-asyncio
and @ShadowJonathan for the code reviews! - @messense for the help with the build pipelines
Example usage:
from robyn import Robyn, static_file, jsonify
app = Robyn(__file__)
callCount = 0
@app.get("/")
async def h():
global callCount
callCount += 1
message = "Called " + str(callCount) + " times"
return message
@app.get("/test")
async def test():
import os
path = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "index.html"))
return static_file(path)
@app.post("/jsonify")
async def json(request):
return jsonify({"hello": "world"})
@app.post("/post")
async def postreq(request):
return bytearray(request["body"]).decode("utf-8")
@app.put("/put")
async def putreq(request):
return bytearray(request["body"]).decode("utf-8")
@app.delete("/delete")
async def deletereq(request):
return bytearray(request["body"]).decode("utf-8")
@app.patch("/patch")
async def patchreq(request):
return bytearray(request["body"]).decode("utf-8")
@app.get("/sleep")
async def sleeper():
await asyncio.sleep(5)
return "sleep function"
@app.get("/blocker")
def blocker():
import time
time.sleep(10)
return "blocker function"
if __name__ == "__main__":
app.add_header("server", "robyn")
app.add_directory(route="/",directory_path="./test_dir/build", index_file="index.html")
app.start(port=5000)
To enable hot reloading, use the following command:
python3 test.py --dev=true
Thank you for all the support during this release! Without the community, this would not be possible! ❤️ 🔥