Code Monkey home page Code Monkey logo

fastbuilder's Introduction

fastbuilder

Build Web Applications with poure Python

๐Ÿ“ฆ Install

pip install fastbuilder


project_folder_struktur/
โ”‚
โ”œโ”€โ”€ static/
โ”‚   โ”œโ”€โ”€ 
โ”œโ”€โ”€ templates/
โ”‚   โ”œโ”€โ”€ 
โ”œโ”€โ”€ .venv
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ build.py



Usage

main.py

from pathlib import Path
import uvicorn
from fastapi import FastAPI, Request, Response
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates


app = FastAPI()

project_path = Path(__file__).parent
templates = Jinja2Templates(project_path / "templates")

static_files = StaticFiles(
    directory=(project_path / "static").resolve(),
    follow_symlink=True,
)
app.mount("/static", static_files, name="static")

# important !!!!!!!!!!!!!!!!!!!!!!!!!!
@app.get("/", response_class=HTMLResponse)
async def read_item(request: Request):
    prefix = request.headers.get(
        "X-Forwarded-Prefix", request.scope.get("root_path", "")
    ) 
    return templates.TemplateResponse(
        "index.html", {"request": request, "prefix": prefix}
    )


@app.get("/favicon.ico", response_class=HTMLResponse)
async def favicon_ico(request: Request):
    return Response(content=b"", media_type="image/x-icon")


@app.get("/exit")
async def logging(request: Request):
    import os
    import signal

    os.kill(os.getpid(), signal.SIGINT)


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

build.py

from fastbuilder import Build

executable = Build(executable_name="server", app_path="main.py")


executable.add_data("static")
executable.add_data("templates")
executable.set_icon("logo.ico")


executable.run_build(
    static_folder="static",
    templates_folder="templates",
    frontend_folder="client",
    frontend_framework="React",
    backend_framework="fastapi",
)

In April 2024, fastbuilder was just publicly released by software architecture Malek Ali at Yellow-SiC Group and is in alpha stage.

Anyone can install and use PyNexumJS, There may be issues, but we are actively working to resolve them

fastbuilder's People

Contributors

aribermeki avatar

Watchers

 avatar

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.