Skip to main content

Installation

Install celestis using pip

  pip install celestis

Documentation

How to run celestis server?

First, you must create the files necessary for your project. You can do this by running the following command:

celestis create-files

The above command will prompt you to enter your project name. Once you provide this information, the necessary files are created in the current directory of the terminal

Say your project name is example. Then, run the following commands on your terminal:

cd example
python server.py

Now, you can navigate to http://localhost:8080 to view your website.

Creating custom routes

Say you want your users to visit your website's about page when they hit the route /about-us.

This can be coded by using the urls.py file. In it, write the following code:

# First value of tuple refers to the route and the second value names the function that returns the HTML for the about page
urls = [("/", "home"), ("/about-us", "about")]

The most important part is to not make the array multiline as that would give an error.

The about function must be created in views.py:

def home():
  return "<h1>Home page</h1>"

def about():
  return "<h1>About us</h1>"

Rendering an HTML template

In the previous example, we returned a string that contained HTML code. But if you want to link an HTML file to the url, you can use the render_template function:

from celestis.view import render as rd

def home():
  # Relative path can be the following: static/home.html
  return rd.render_template("relative/path/to/home.html")

def about():
  # Relative path can be the following: static/about.html
  return rd.render_template("relative/path/to/about.html")

Database usage

Open up a terminal in your project directory and then run the following command:

celestis create-db

Then, create a models.py file in your project directory. Here, you can create blueprints for your database tables. Below is a sample code:

def users():
    email = "TEXT PRIMARY KEY"
    name = "TEXT"
    password = "TEXT"

    return {
        "email": email,
        "name": name,
        "password": password
    }

Then, run the following command:

celestis update-db

Below are the CRUD operations you can perform:

from celestis.model import database
import os

users = database.Model("users", os.getcwd()) # Give the model name as an input to the class and the second parameter as a os.getcwd()
users.add({
    "email": "example@gmail.com",
    "name": "example",
    "password": "example@123"
})

record = users.find({
    "email": "example@gmail.com",
})

users.update(record, password="example@321")
users.delete(record)

Authors

Metadata

Release files for celestis 2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for celestis 2.2
File Size Uploaded Provenance Actions
celestis-2.2.tar.gz 6.4 kB Without provenance Details for celestis-2.2.tar.gz

Release files / celestis-2.2.tar.gz

Download URL celestis-2.2.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c6a0b5f97bb28ed2e0adb1404fde673fcdb0cdac7caa103c886fbebdaa8aa2fa
BLAKE2b-256 checksum
How to use checksums
e86edade4e3878284c5453199cec249cb7b00103d7994a0ab3a256930c4e7f10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.0

Security for celestis 2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page