GithubHelp home page GithubHelp logo

astra's Introduction

Astra ๐Ÿš€

Astra is a tiny Flask-esque web framework. It provides you with basic Request and Response objects, as well as more advanced routing through the Blueprint object. URL parameters are supported. It requires no outside dependencies (not even Werkzeug or WebOb, two awesome projects).

As someone who writes a lot of backend code, I wrote this in order to learn how web frameworks work. As such, I make no guarantees about the performance/security of this code, and I highly reccomend that you do not use it in production. You may find it useful in a small personal project, though ๐Ÿ˜„ .

Installing

git clone https://github.com/gurleens2000/astra-web
cd astra-web
pip install .

Example

from astra.wsgi import Astra
from astra.response import Response
from astra.blueprints import Blueprint

app = Astra()

@app.route("/", methods=["GET"])
def hello(request):
    return Response("Hello, world!")

@app.route("/user/:name")
def username(request):
    name = request.params.get("name")
    # Response supports text as well as dicts/lists (serialized as JSON)
    return Response({"msg": f"Hello, {name}!"})

blueprint = Blueprint("/blueprint")

@blueprint.path("/")
def blueprint_test(request):
    return Response("Hello from a blueprint!")

app.register_blueprint(blueprint)

if __name__ == "__main__":
    app.run(8000)

This will serve the app on http://localhost:8000/ using wsgiref, Python's built-in WSGI server. You can use any WSGI-compliant server, such as Gunicorn. The supplied run.sh script runs the example app via Gunicorn.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.