Arkhos Documentation

Getting started guide Example apps Video intro

Requests

When your app is triggered (see triggers below), Arkhos will call the function arkhos_handler in main.py. It will be passed a request object. def arkhos_handler(request): The request object will have these attributes

Attribute Description & Example
method

The event that triggered the app: GET, POST, SCHEDULED, EMAIL

if request.method == "GET":
		return arkhos.render("index.html")
GET A dict of url GET parameters
eg. https://my-app.arkhosapp.com?name=lola
name = arkhos.GET["name"]
	print(name) # lola
body The HTTP (or email) request body, string
json The HTTP request body parsed as json, dictionary
request.json["some_key"
headers HTTP request headers, dictionary
path The url path, string
if request.path == "/":
	return arkhos.render("index.html")

elif request.path == "/api"
	return arkhos.json({"data":"more data"})

Responses

Your arkhos_handler should return one of the responses below. All responses also accept a status and dict of headers

Response type Description & Example
arkhos.json

Return a dict as json

return arkhos.json({"user_id": "abc1234"})
arkhos.http

Return html

return arkhos.http("<h1>Hi</h1>")
return arkhos.http(
	"<h1>Not found</h1>",
	status=404
)
arkhos.render

Render an html file. Uses the jinja templating language.

return arkhos.render("index.html")
return arkhos.render("profile.html", {"first_name": "marvin"}
<!-- profile.html -->
<h1>Hello  {{first_name}}</h1>

Static Files (.js, .css, .jpg)

Any files in /static folder are available at my-app.arkhosapp.com/static/

my-app
  |____main.py
  |____profile.html
  |____requirements.txt
  |____static
  | |____theme.css

theme.css is available at https://my-app.arkhosapp.com/static/theme.css

Key/Value and Storage

Arkhos comes with a built-in key/value store

Attribute Description & Example
arkhos.set(key, value)

Store a key, value. key should be a string. value can be string, int, float, boolean, or datetime

arkhos.set("the_answer", "42")
arkhos.set("updated_at", datetime.datetime.now())
arkhos.get(key)

arkhos.get(key, default_value)

Get a key. Use default_value if the key does not exist.

arkhos.get("the_answer")
arkhos.get("website_visitors", 0)
return arkhos.json({
	"last_upate_at": arkhos.get("updated_at")
})

Dependencies: requirements.txt

Arkhos will automatically install any dependencies in requirements.txt

requests==2.31.0
certifi==2024.2.2
charset-normalizer==3.3.2
idna==3.6
urllib3==2.2.1

Testing locally

Testing your app locally is easy 🤞

$ pip install arkhos

# from the project root folder, run
$ arkhos

# test a POST request to /api
$ arkhos POST --path "/api"

Triggers

When you create a new Arkhos app, you can choose the name of the application, eg. my-app. The app will be available at https://my-app.arkhosapp.com.

You can schedule your app to run using Arkhos cron (coming soon)

You can trigger your app by emailing my-app@arkhosapp.com (coming soon)

You can trigger your app from Slack or Discord (coming eventually)