diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 44d3335..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms - -patreon: Cactochan # Replace with a single Patreon username diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index dd84ea7..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bbcbbe7..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/april.py b/april.py deleted file mode 100644 index 7e80d6b..0000000 --- a/april.py +++ /dev/null @@ -1,81 +0,0 @@ -def main(): - a = """ -April v 1.0.0 - -A language for programming API's - -# Some cool features : - - - Maskes use Of FastAPI - - - Show API Statistics (If required) - - Support Multiple Languages - - - Generate Documentation ( 'GEN_DOC {eg : /e/e/doc }' ) - - Rate Limiting ( 'RATE_LIMIT {how many per min}' ) - - Disallow Private IP ( 'DISALLOW_PRIVATE_IP' ) - - Not Allowed IP ( 'NOT_ALLOWED_IP {textfile.txt each ip sep by \n}' ) - - - Other keywords: - - TITLE '{}' - - VERSION {} - - DESC '{}' - - - Use '--': - - --L = {call-per-min} (set limiting for a single endpoint) - - --N = {Name for the end point} (to put in docs) - - --D = {Desc for the end point} (to put in docs) - - -# Installng Redis and running manually -- sudo apt-get install redis-server -- Using uvicorn = uvicorn main:app --host 0.0.0.0 --port 80 - -Auther : Merwin - """ - help_ = """ -\t-h Help -\t-a About -\t-c Compile eg: april -c | Compiles \n\t the code to python saved in name file_apl.py (if the og name was file.apl) -\t-r Run eg: april -r -\t-v Version - """ - - import sys - import os - - sys = sys.argv - - if len(sys) == 1: - print(help_) - exit() - - if sys[1] == "-c": - os.system(f"python3 compiler.py {sys[2]}") - - elif sys[1] == "-a": - print(a) - - elif sys[1] == "-h": - print(help_) - - elif sys[1] == "-r": - nn = sys[2].split(".")[0:-1] - n = "" - for e in nn: - n += e - n += "_apl" - - os.system(f"python3 compiler.py {sys[2]}") - os.system(f"uvicorn {n}:app --host {sys[3].split(':')[0]} --port {sys[3].split(':')[1]}") - - elif sys[1] == "-v": - print("1.0.0") - - else: - print("Command Not Found") - -if __name__ == '__main__': - main() - - diff --git a/compiler.py b/compiler.py deleted file mode 100644 index 99742fc..0000000 --- a/compiler.py +++ /dev/null @@ -1,471 +0,0 @@ -""" -April compiler v 1.0.0 - -Author : Merwin -""" - - -import os -import sys -import json -import random -import hashlib -from rich import print - - - - -base_code = """ -############################################## -#Auto-generated code by April compiler v1.0.0 -############################################## - - -from fastapi import FastAPI, Request, Response, status, Depends -from fastapi_limiter import FastAPILimiter -from fastapi_limiter.depends import RateLimiter -import redis.asyncio as redis -from contextlib import asynccontextmanager -import aioredis -import ipaddress -import random -import json -import time -import os - - -ON_GOING = [] - -NOT_ALLOWED = [] - -if ___NOT_ALLOWED_IP___ != None: - f = open(___NOT_ALLOWED_IP___, "r") - NOT_ALLOWED = f.read().split("\\n") - f.close() - - - -def gen_new_id(): - - global ON_GOING - - while True: - i = random.randint(1000000,900000000000000000000) - if not i in ON_GOING: - ON_GOING.append(i) - return i - - -def wait_for_change(cur_id): - while True: - time.sleep(0.005) - if os.path.exists("." + str(cur_id) + ".output"): - f = open("." + str(cur_id) + ".output", "r") - raw_data = f.read() - - if raw_data == "": - continue - - data = json.loads(raw_data) - - f.close() - os.remove("." + str(cur_id) + ".output") - os.remove("." + str(cur_id) + ".input") - - return data - - -def check_ip(ip): - - if ___DISALLOW_PRIVATE_IP___: - return not ipaddress.ip_address(ip).is_private - - if ip in NOT_ALLOWED: - return False - - return True - - -RATE_LIMIT = ___RATE_LIMIT___ -tags_metadata = ___TAGS___ - -@asynccontextmanager -async def lifespan(_: FastAPI): - if RATE_LIMIT: - redis_connection = redis.from_url("redis://localhost:6379", encoding="utf8") - await FastAPILimiter.init(redis_connection) - yield - await FastAPILimiter.close() - - - -app = FastAPI(title= "___TITLE___", version= "___VERSION___", description= "___DESC___", docs_url= "___IF_DOCS___", redoc_url= None, - openapi_tags=tags_metadata, lifespan=lifespan) - - - - -""" - - -api_code = """ - - -@app.__type__("__end_point__", ___ADD___) -async def __fun_name__(__params__ request: Request, response: Response): - cli_ip = request.client.host - if not check_ip(cli_ip): - return {"err" : "Not Allowed"} - - current_id = gen_new_id() - f = open("." + str(current_id) + ".input", "w") - f.write(json.dumps({"request" : dict(request), "input" : __get_params__})) - f.close() - os.system(f"__command__ {current_id}") - data = wait_for_change(current_id) - try: - resp = data["output"] - except: - resp = "" - try: - response.headers = data["headers"] - except: - pass - status = 200 - try: - if data["status"] != "": - status = data["status"] - except: - pass - - response.status_code = status - ON_GOING.remove(current_id) - return resp - -""" - - - - -def lts(s): - str1 = "" - - for ele in s: - str1 += ele - - return str1 - - - - -def get_params(end_point): - params = [] - - e = end_point.split("/") - - while True: - try: - e.remove("") - except: - break - - for x in e: - if x.startswith("{"): - x = x.replace("{", "") - x = x.replace("}", "") - - params.append(x) - - return params - - - -def format_params(params): - a = "" - for e in params: - a += e + ", " - - return a - - - -def get_return_params(params): - a = "{\n" - - for e in params: - a += f"\t\t '{e}' : {e}, \n" - - a += "}" - - return a - - - -def get_query_params(params): - query_params = [] - - for e in params.split("<"): - if e.endswith(">"): - query_params.append(e.replace(">", "")) - - return params.split("<")[0] , query_params - - - -def cure_gen_command(command): - split_ = command.split(":") - main_part = split_[0] - cmd = split_[1] - - return main_part.replace(" ", "") + ":" + cmd - - -def import_apls(commands): - extras = "\n" - for e in commands: - if e.startswith("IMPORT"): - e = e.replace("IMPORT", "") - e = e.replace(" ", "") - e = e.replace("\n", "") - e = e.replace("\t", "") - - extras = e - - try: - f = open(extra + ".apl", "r") - extras += f.read() - f.close() - except: - print(f"WARN : Issue with using '{extra}.apl' ") - - x = ["GEN_DOC","RATE_LIMIT","TITLE","VERSION","DESC","DISALLOW_PRIVATE_IP","NOT_ALLOWED_IP","IMPORT", "//"] - extras = extras.split("\n") - for e in extras: - for z in x: - if e.startswith(z): - extras.remove(e) - break - - return extras - -def compile(filename, newfilename): - - fun_id = 0 - - - if not os.path.exists(filename): - print(f"[red] ERROR : Compiler - > '{filename}' Not found [/red]") - return None - - f = open(filename) - commands = f.read().split("\n") - f.close() - - extras = import_apls(commands) - - commands = commands + extras - - compiled_code = base_code - - - NAME_DESC = [] - - ___IF_DOCS___ = None - RATE_LIMIT = False - RATE_LIMIT_PER = None - TITLE = None - VERSION = None - DESC = None - NOT_ALLOWED_IP = "None" - DISALLOW_PRIVATE_IP = False - - for e in commands: - if e.startswith("//"): - continue - - if "//" in e: - e = e.split("//")[0] - - if e in ["\n", "\t", " ", ""]: - continue - - if e.startswith("GEN_DOC"): - e = e.replace("GEN_DOC", "") - e = e.replace(" ", "") - e = e.replace("\n", "") - e = e.replace("\t", "") - - if not e.startswith("/"): - e = "/" + e - - ___IF_DOCS___ = e - - continue - - - elif e.startswith("RATE_LIMIT"): - e = e.replace("RATE_LIMIT", "") - e = e.replace(" ", "") - e = e.replace("\n", "") - e = e.replace("\t", "") - - - RATE_LIMIT = True - RATE_LIMIT_PER = e - - continue - - elif e.startswith("TITLE"): - e = e.replace("TITLE", "") - e = e.split("'")[1] - - TITLE = e - - continue - - elif e.startswith("VERSION"): - e = e.replace("VERSION", "") - e = e.replace(" ", "") - e = e.replace("\n", "") - e = e.replace("\t", "") - - VERSION = e - - continue - - elif e.startswith("DESC"): - e = e.replace("DESC", "") - e = e.split("'")[1] - - DESC = e - - continue - - elif e.startswith("DISALLOW_PRIVATE_IP"): - - DISALLOW_PRIVATE_IP = True - - continue - - elif e.startswith("NOT_ALLOWED_IP"): - e = e.replace("NOT_ALLOWED_IP", "") - e = e.replace(" ", "") - e = e.replace("\n", "") - e = e.replace("\t", "") - - NOT_ALLOWED_IP = f'"e"' - - continue - - - e = cure_gen_command(e) - - type_ = e.split("(")[0] - - end_point = lts(e.split("(")[1]) - end_point = end_point.split(")")[0] - - end_point , query_params = get_query_params(end_point) - - params = get_params(end_point) + query_params - - formated_params = format_params(params) - return_params = get_return_params(params) - - command = e.split(":")[1] - - LIMIT = None - - ## CHecking for '--' - - z = e.split(":")[0] - z = z.split(")")[1] - z = z.split("--") - - DESC_E = "" - NAME_E = "" - NAME_DESC_ = {} - - for e in z: - if e.startswith("L"): - LIMIT = e.split("=")[1].replace(" ", "") - - elif e.startswith("N"): - NAME_E = e.split("=")[1] - - elif e.startswith("D"): - DESC_E = e.split("=")[1] - - if NAME_E != "": - NAME_DESC_.setdefault("name", NAME_E) - NAME_DESC_.setdefault("description", DESC_E) - - NAME_DESC.append(NAME_DESC_) - - - chunk = api_code.replace("__type__", type_) - chunk = chunk.replace("__end_point__", end_point) - - chunk = chunk.replace("__fun_name__", f"_{fun_id}") - fun_id += 1 - - chunk = chunk.replace("__params__", formated_params) - chunk = chunk.replace("__get_params__", return_params) - chunk = chunk.replace("__command__", command) - - if LIMIT != None: - if NAME_E != "": - chunk = chunk.replace("___ADD___", f"dependencies=[Depends(RateLimiter(times={LIMIT}, seconds=60))], tags=['{NAME_E}']") - else: - chunk = chunk.replace("___ADD___", f"dependencies=[Depends(RateLimiter(times={LIMIT}, seconds=60))]") - elif RATE_LIMIT: - if NAME_E != "": - chunk = chunk.replace("___ADD___", f"dependencies=[Depends(RateLimiter(times={RATE_LIMIT_PER}, seconds=60))], tags=['{NAME_E}']") - else: - chunk = chunk.replace("___ADD___", f"dependencies=[Depends(RateLimiter(times={RATE_LIMIT_PER}, seconds=60))]") - else: - if NAME_E != "": - chunk = chunk.replace("___ADD___", f"tags=['{NAME_E}']") - compiled_code += "\n" + chunk - - - compiled_code = compiled_code.replace("___IF_DOCS___", ___IF_DOCS___) - compiled_code = compiled_code.replace("___RATE_LIMIT___", f"{RATE_LIMIT}") - compiled_code = compiled_code.replace("___TITLE___", TITLE) - compiled_code = compiled_code.replace("___VERSION___", VERSION) - compiled_code = compiled_code.replace("___DESC___", DESC) - compiled_code = compiled_code.replace("___NOT_ALLOWED_IP___", f'{NOT_ALLOWED_IP}') - compiled_code = compiled_code.replace("___DISALLOW_PRIVATE_IP___", f"{DISALLOW_PRIVATE_IP}") - compiled_code = compiled_code.replace("___TAGS___", str(NAME_DESC)) - - runner = f""" - -# RUNNING -import uvicorn -if __name__ == "__main__": - uvicorn.run("{newfilename.replace(".py", "")}:app") - - """ - - compiled_code += runner - - f_ = open(newfilename, "w") - f_.write(compiled_code) - f_.close() - - -try: - filename = sys.argv[1] -except: - print("[red] ERROR : Compiler - > Filename not provided[/red]") - quit() - -print(f"[blue] MSG : Compiler - > Compiled file's name = {filename.replace('.', '_')}.py [/blue]") -newfilename = filename.replace(".", "_") + ".py" - -print("[blue] MSG : Compiler - > Compiling file[/blue]") - -compile(filename, newfilename) - - - diff --git a/dart/connect_april.dart b/dart/connect_april.dart deleted file mode 100644 index b9cbe74..0000000 --- a/dart/connect_april.dart +++ /dev/null @@ -1,31 +0,0 @@ -// april.dart - -import 'dart:convert'; -import 'dart:io'; - -class ConnectApril { - static Map? recvRequest() { - final n = int.parse(Platform.args.last!); - final filePath = '.$n.input'; - - try { - final data = File(filePath).readAsStringSync(); - return json.decode(data); - } catch (e) { - print('Error reading file: $filePath'); - return null; - } - } - - static void sendResponse(Map response) { - final n = int.parse(Platform.args.last!); - final filePath = '.$n.output'; - - try { - File(filePath).writeAsStringSync(json.encode(response)); - } catch (e) { - print('Error writing file: $filePath'); - } - } -} - diff --git a/dart/example.dart b/dart/example.dart deleted file mode 100644 index 0aab326..0000000 --- a/dart/example.dart +++ /dev/null @@ -1,14 +0,0 @@ -// main.dart - -import 'april.dart'; - -void main() { - // Example usage: - final requestData = ConnectApril.recvRequest(); - print('Received data: $requestData'); - - final responseData = {'output': 'Hello from, Dart!'}; - ConnectApril.sendResponse(responseData); - print('Response sent.'); -} - diff --git a/docs/author/index.html b/docs/author/index.html new file mode 100644 index 0000000..fd7aab0 --- /dev/null +++ b/docs/author/index.html @@ -0,0 +1,66 @@ + + + + + + April | Documentation + + + + +
+
+ + +
+

Author

+
+

April was created by Merwin M.

+
+

Just an another developer...

+
+ +
+

+ + + + + + + +

+ + +
+ + +
+ + +
+ + + + +

+

+
+ + + \ No newline at end of file diff --git a/docs/contributing/index.html b/docs/contributing/index.html new file mode 100644 index 0000000..31da46b --- /dev/null +++ b/docs/contributing/index.html @@ -0,0 +1,43 @@ + + + + + + April | Documentation + + + + +
+
+ + +
+

Contributing

+
+

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

+
    +
  • If you have suggestions for adding or removing projects, feel free to open an issue to discuss it, or directly create a pull request after you edit the README.md file with necessary changes.
  • +
  • Please make sure you check your spelling and grammar.
  • +
  • Create individual PR for each suggestion.
  • +
+
+
+ + + \ No newline at end of file diff --git a/docs/gettingstarted/index.html b/docs/gettingstarted/index.html new file mode 100644 index 0000000..40fa9ef --- /dev/null +++ b/docs/gettingstarted/index.html @@ -0,0 +1,67 @@ + + + + + + April | Documentation + + + + +
+
+ + +
+

Getting Started

+
+

Prerequirements

+
    +
  1. Python3
  2. +
  3. Pip3
  4. +
  5. Redis server
  6. +
+
+

Installaition

+

Windows:

+
pip install aprillang
+

Linux/MacOs

+
pip3 install aprillang
+

Usage

+

Get the list of allowed commands

+
april -h
+

Get info of the language

+
april -a
+

Compile an .apl file (april file):

+
    +
  1. This converts the april code to python3 code
  2. +
  3. Compiled file is saved as filename without extention apl + '_apl.py'
  4. +
+
april -c file.apl
+

Run an .apl file (start the API server):

+
    +
  1. Format for the command is - april -r host:port
  2. +
+
april -r file.apl 0.0.0.0:8080
+

Get the version of april:

+
april -v
+
+
+ + + \ No newline at end of file diff --git a/docs/license/index.html b/docs/license/index.html new file mode 100644 index 0000000..782c4ae --- /dev/null +++ b/docs/license/index.html @@ -0,0 +1,59 @@ + + + + + + April | Documentation + + + + +
+
+ + +
+

License

+
+ MIT License + +Copyright (c) 2023 Cactochan +

+Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions:

+ +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software.

+ +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +
+
+ + + \ No newline at end of file diff --git a/docs/packages/index.html b/docs/packages/index.html new file mode 100644 index 0000000..df02c5f --- /dev/null +++ b/docs/packages/index.html @@ -0,0 +1,101 @@ + + + + + + April | Documentation + + + + +
+
+ + +
+

Packages

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LanguageLinkCreatorInfo
PythonLinkmerwin-asmLink
LuaLinkmerwin-asmLink
JSLinkaxoraxLink
TSLinkmerwin-asmLink
GoLinkmerwin-asmLink
RustLinkmerwin-asmLink
PHPLinkmerwin-asmLink
DartLinkmerwin-asmLink
RubyLinkmerwin-asmLink
+
+ + + \ No newline at end of file diff --git a/docs/support/index.html b/docs/support/index.html new file mode 100644 index 0000000..faaa7ba --- /dev/null +++ b/docs/support/index.html @@ -0,0 +1,39 @@ + + + + + + April | Documentation + + + + +
+
+ + +
+

Support

+
+

For support feel free to create an in issue or send us a message in our DISCORD SERVER

+ +
+
+ + + \ No newline at end of file diff --git a/examples/bmi_calculator/api.apl b/examples/bmi_calculator/api.apl deleted file mode 100644 index c907ff3..0000000 --- a/examples/bmi_calculator/api.apl +++ /dev/null @@ -1,7 +0,0 @@ -// Set API information -TITLE 'BMI Calculator API' -VERSION 1.0 -DESC 'An API for calculating Body Mass Index (BMI)' - -// Define endpoint to calculate BMI -post('/bmi') : python3 bmi_handler.py calculate_bmi diff --git a/examples/bmi_calculator/bmi_handler.py b/examples/bmi_calculator/bmi_handler.py deleted file mode 100644 index 5da5d6c..0000000 --- a/examples/bmi_calculator/bmi_handler.py +++ /dev/null @@ -1,43 +0,0 @@ -# Import necessary modules -import json -from connect_april import April - -# Function to calculate BMI -def calculate_bmi(): - # Read input from the input file using the connect_april package - input_data = April().recv_request() - - # Extract height and weight from input - height = float(input_data["input"]["height"]) - weight = float(input_data["input"]["weight"]) - - # Calculate BMI - bmi = weight / (height ** 2) - - # Determine BMI category - bmi_category = "" - if bmi < 18.5: - bmi_category = "Underweight" - elif 18.5 <= bmi < 24.9: - bmi_category = "Normal Weight" - elif 25 <= bmi < 29.9: - bmi_category = "Overweight" - else: - bmi_category = "Obese" - - # Prepare the output data - output_data = { - "headers": {"Content-Type": "application/json"}, - "status": 200, - "output": { - "bmi": bmi, - "category": bmi_category - } - } - - # Write output to the output file using the connect_april package - April().send_response(output_data) - -# Execute the calculate_bmi function if the script is run directly -if __name__ == "__main__": - calculate_bmi() diff --git a/examples/time_api/time.apl b/examples/time_api/time.apl deleted file mode 100644 index 13fa8d3..0000000 --- a/examples/time_api/time.apl +++ /dev/null @@ -1,15 +0,0 @@ -// Import required packages -IMPORT std_lib - -// Set API information -TITLE 'Time API' -VERSION 1.0 -DESC 'An API to get the current time' - -// Define an endpoint for getting the current time -get('/time') : python3 time_handler.py - -// Define Python backend code in a separate file (time_handler.py) -// This file will be executed when the '/time' endpoint is accessed -// The Python script should read input from the input file and write output to the output file - diff --git a/examples/time_api/time_handler.py b/examples/time_api/time_handler.py deleted file mode 100644 index 93f60b2..0000000 --- a/examples/time_api/time_handler.py +++ /dev/null @@ -1,21 +0,0 @@ -# Import the connect_april package -import connect_april - -april = connect_april.April() - -# Read input from the input file using the connect_april package -input_data = april.recv_request() - -# Get the current time -from datetime import datetime -current_time = str(datetime.now()) - -# Prepare the output data -output_data = { - "headers": {"Content-Type": "application/json"}, - "status": 200, - "output": {"current_time": current_time} -} - -# Write output to the output file using the connect_april package -april.send_response(output_data) diff --git a/examples/todo_app/api.apl b/examples/todo_app/api.apl deleted file mode 100644 index d721fc8..0000000 --- a/examples/todo_app/api.apl +++ /dev/null @@ -1,13 +0,0 @@ -// Set API information -TITLE 'Todo API' -VERSION 1.0 -DESC 'An API for a simple todo app' - -// Define endpoint to get all todos -get('/todos') : python3 todo_handler.py list_todos - -// Define endpoint to add a new todo -post('/todos') : python3 todo_handler.py add_todo - -// Define endpoint to mark a todo as completed -put('/todos/{todo_id}') : python3 todo_handler.py complete_todo diff --git a/examples/todo_app/todo_handler.py b/examples/todo_app/todo_handler.py deleted file mode 100644 index 2ec10f7..0000000 --- a/examples/todo_app/todo_handler.py +++ /dev/null @@ -1,56 +0,0 @@ -# Import necessary modules -import json -from connect_april import April - -# Function to list all todos -def list_todos(): - response = { - "headers": {"Content-Type": "application/json"}, - "status": 200, - "output": {"todos": todos} - } - April().send_response(response) - -# Function to add a new todo -def add_todo(): - input_data = April().recv_request() - new_todo = input_data["input"]["todo"] - todos.append(new_todo) - - response = { - "headers": {"Content-Type": "application/json"}, - "status": 201, - "output": {"message": "Todo added successfully"} - } - April().send_response(response) - -# Function to mark a todo as completed -def complete_todo(): - input_data = April().recv_request() - todo_id = input_data["input"]["todo_id"] - - try: - todos[todo_id]['completed'] = True - response = { - "headers": {"Content-Type": "application/json"}, - "status": 200, - "output": {"message": f"Todo {todo_id} marked as completed"} - } - except IndexError: - response = { - "headers": {"Content-Type": "application/json"}, - "status": 404, - "output": {"error": "Todo not found"} - } - - April().send_response(response) - -# Execute the corresponding function based on the command-line argument -if __name__ == "__main__": - command = sys.argv[2] - if command == "list_todos": - list_todos() - elif command == "add_todo": - add_todo() - elif command == "complete_todo": - complete_todo() diff --git a/go/connect_april.go b/go/connect_april.go deleted file mode 100644 index d66c1d2..0000000 --- a/go/connect_april.go +++ /dev/null @@ -1,46 +0,0 @@ - - -package connect_april - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "os" -) - -// RecvRequest reads a file based on the command-line argument and returns the parsed JSON data. -func RecvRequest() (map[string]interface{}, error) { - n := os.Args[len(os.Args)-1] - filePath := fmt.Sprintf(".%s.input", n) - - data, err := ioutil.ReadFile(filePath) - if err != nil { - return nil, fmt.Errorf("error reading file: %s", filePath) - } - - var jsonData map[string]interface{} - if err := json.Unmarshal(data, &jsonData); err != nil { - return nil, fmt.Errorf("error parsing JSON data: %v", err) - } - - return jsonData, nil -} - -// SendResponse writes the provided response as JSON to a file based on the command-line argument. -func SendResponse(response map[string]interface{}) error { - n := os.Args[len(os.Args)-1] - filePath := fmt.Sprintf(".%s.output", n) - - responseJSON, err := json.Marshal(response) - if err != nil { - return fmt.Errorf("error encoding response as JSON: %v", err) - } - - if err := ioutil.WriteFile(filePath, responseJSON, 0644); err != nil { - return fmt.Errorf("error writing file: %s", filePath) - } - - return nil -} - diff --git a/go/example.go b/go/example.go deleted file mode 100644 index d899f33..0000000 --- a/go/example.go +++ /dev/null @@ -1,26 +0,0 @@ -// example.go - -package main - -import ( - "fmt" - "connect_april" // Adjust the import path based on your project structure -) - -func main() { - // Example usage: - requestData, err := connect_april.RecvRequest() - if err != nil { - fmt.Println(err) - return - } - fmt.Println("Received data:", requestData) - - responseData := map[string]interface{}{"output": "Hello from, Go!"} - if err := connect_april.SendResponse(responseData); err != nil { - fmt.Println(err) - return - } - fmt.Println("Response sent.") -} - diff --git a/index.html b/index.html new file mode 100644 index 0000000..730d531 --- /dev/null +++ b/index.html @@ -0,0 +1,42 @@ + + + + + + April | Documentation + + + + +
+
+ + +
+

About

+
+ This language was made for making API's great ease and more efficiency. +

+ The language connects each API endpoint to a specific program/command, in case you want to write the code for the endpoint /home in python and /generate in Cpp - this can be done. +

+ The language have packages for multiple languages for adapting april to the wanted language (some packages are made by the community too!!) . In case you dont find the required package for utilizing april in your wanted language - don't worry its easy to make a package for your own. +
+
+ + + \ No newline at end of file diff --git a/js/connect_april.js b/js/connect_april.js deleted file mode 100644 index da35e13..0000000 --- a/js/connect_april.js +++ /dev/null @@ -1,27 +0,0 @@ -const fs = require('fs'); - -class ConnectApril { - static recv_request() { - const n = process.argv[process.argv.length - 1]; - const filePath = `.${n}.input`; - - try { - const data = fs.readFileSync(filePath, 'utf8'); - return JSON.parse(data); - } catch (err) { - console.error(err); - return null; - } - } - - static send_response(response) { - const n = process.argv[process.argv.length - 1]; - const filePath = `.${n}.output`; - - try { - fs.writeFileSync(filePath, JSON.stringify(response)); - } catch (err) { - console.error(err); - } - } -} diff --git a/js/example.js b/js/example.js deleted file mode 100644 index 57a1a14..0000000 --- a/js/example.js +++ /dev/null @@ -1,10 +0,0 @@ -const ConnectApril = require('./connect_april'); // Assuming the JavaScript file is named 'April.js' - -// Example usage: -const requestData = ConnectApril.recv_request(); -console.log('Received data:', requestData); - -const responseData = { output: 'Hello, World!' }; -ConnectApril.send_response(responseData); -console.log('Response sent.'); - diff --git a/lua/connect_april.lua b/lua/connect_april.lua deleted file mode 100644 index ff3c356..0000000 --- a/lua/connect_april.lua +++ /dev/null @@ -1,31 +0,0 @@ -local connect_april = {} - -function connect_april.recv_request() - local n = arg[#arg] - local filePath = '.' .. n .. '.input' - - local file = io.open(filePath, 'r') - if file then - local data = file:read('*a') - file:close() - return json.decode(data) - else - print('Error reading file:', filePath) - return nil - end -end - -function connect_april.send_response(response) - local n = arg[#arg] - local filePath = '.' .. n .. '.output' - - local file, err = io.open(filePath, 'w') - if file then - file:write(json.encode(response)) - file:close() - else - print('Error writing file:', err) - end -end - -return connect_april diff --git a/lua/example.lua b/lua/example.lua deleted file mode 100644 index bbd273c..0000000 --- a/lua/example.lua +++ /dev/null @@ -1,13 +0,0 @@ --- main.lua - -local connect_april = require("connect_april") -local json = require("json") -- Assuming you have a JSON library for Lua - --- Example usage: -local requestData = connect_april.recv_request() -print('Received data:', requestData) - -local responseData = { output = 'Hello from, Lua!' } -connect_april.send_response(responseData) -print('Response sent.') - diff --git a/lua/info.md b/lua/info.md deleted file mode 100644 index a583ff4..0000000 --- a/lua/info.md +++ /dev/null @@ -1 +0,0 @@ -Make sure to have the connect_april.lua and json.lua (or any other JSON library for Lua) files accessible in the Lua path or the same directory as your main Lua script. diff --git a/php/connect_april.php b/php/connect_april.php deleted file mode 100644 index bb8b3fe..0000000 --- a/php/connect_april.php +++ /dev/null @@ -1,29 +0,0 @@ - - diff --git a/php/example.php b/php/example.php deleted file mode 100644 index 5b22574..0000000 --- a/php/example.php +++ /dev/null @@ -1,13 +0,0 @@ - 'Hello from, PHP!']; -ConnectApril::send_response($responseData); -echo "Response sent.\n"; -?> - diff --git a/php/info.md b/php/info.md deleted file mode 100644 index f7bc6b7..0000000 --- a/php/info.md +++ /dev/null @@ -1,4 +0,0 @@ -Run the example script using the command: -``` -php example.php -``` diff --git a/python/connect_april.py b/python/connect_april.py deleted file mode 100644 index 53fdf9a..0000000 --- a/python/connect_april.py +++ /dev/null @@ -1,32 +0,0 @@ -""" -AprilAPI 1.0.0 - -Module to work with april - -Author : Merwin -""" - -import json -import sys - - -class April: - def __init__(self): - pass - - def recv_request(self): - n = sys.argv[-1] - f = open("." + str(current_id) + ".input", "r") - d = json.loads(f.read()) - f.close() - - return d - - def send_response(self, response): - n = sys.argv[-1] - f = "." + str(n) + ".output" - f = open(f, "w") - f.write(json.dumps(response)) - f.close() - - diff --git a/ruby/connect_april.rb b/ruby/connect_april.rb deleted file mode 100644 index 7e3e1fb..0000000 --- a/ruby/connect_april.rb +++ /dev/null @@ -1,30 +0,0 @@ -# connect_april.rb - -require 'json' - -module ConnectApril - def self.recv_request - n = ARGV[-1] - file_path = ".#{n}.input" - - begin - data = File.read(file_path) - JSON.parse(data) - rescue StandardError => e - puts "Error reading file: #{file_path}" - nil - end - end - - def self.send_response(response) - n = ARGV[-1] - file_path = ".#{n}.output" - - begin - File.write(file_path, JSON.generate(response)) - rescue StandardError => e - puts "Error writing file: #{file_path}" - end - end -end - diff --git a/ruby/example.rb b/ruby/example.rb deleted file mode 100644 index 30b9896..0000000 --- a/ruby/example.rb +++ /dev/null @@ -1,12 +0,0 @@ -# main.rb - -require_relative 'connect_april' - -# Example usage: -request_data = ConnectApril.recv_request -puts "Received data: #{request_data}" - -response_data = { 'output' => 'Hello from, Ruby!' } -ConnectApril.send_response(response_data) -puts 'Response sent.' - diff --git a/ruby/info.md b/ruby/info.md deleted file mode 100644 index 03a6227..0000000 --- a/ruby/info.md +++ /dev/null @@ -1,4 +0,0 @@ -Run the Ruby file using the command: -``` -ruby main.rb -``` diff --git a/rust/Cargo.toml b/rust/Cargo.toml deleted file mode 100644 index b28a0f9..0000000 --- a/rust/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[dependencies] -serde = { version = "1", features = ["derive"] } -serde_json = "1" - diff --git a/rust/connect_april.rs b/rust/connect_april.rs deleted file mode 100644 index cc93bfc..0000000 --- a/rust/connect_april.rs +++ /dev/null @@ -1,33 +0,0 @@ -use std::error::Error; -use std::fs; -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Deserialize, Serialize)] -pub struct ConnectApril; - -impl ConnectApril { - pub fn recv_request() -> Result> - where T: Deserialize<'static'>, - { - let n = std::env::args().last().expect("Please provide a command-line argument"); - let file_path = format!("./{}.input", n); - - let data = fs::read_to_string(file_path)?; - let parsed_data = serde_json::from_str(&data)?; - - Ok(parsed_data) - } - - pub fn send_response(response: &T) -> Result<(), Box> - where T: Serialize, - { - let n = std::env::args().last().expect("Please provide a command-line argument"); - let file_path = format!("./{}.output", n); - - let response_json = serde_json::to_string_pretty(response)?; - fs::write(file_path, response_json)?; - - Ok(()) - } -} - diff --git a/rust/example.rs b/rust/example.rs deleted file mode 100644 index ed744ad..0000000 --- a/rust/example.rs +++ /dev/null @@ -1,28 +0,0 @@ -use connect_april::ConnectApril; - -#[derive(Debug, serde::Deserialize, serde::Serialize)] -struct RequestData { - // Define your fields here - field1: String, - field2: i32, -} - -#[derive(Debug, serde::Deserialize, serde::Serialize)] -struct ResponseData { - message: String, -} - -fn main() { - // Example usage: - let request_data: RequestData = ConnectApril::recv_request().expect("Error receiving data"); - println!("Received data: {:#?}", request_data); - - // Assuming you have a struct to send as a response - let response_data = ResponseData { - message: format!("Hello from, Rust! Received: {:?}", request_data), - }; - - ConnectApril::send_response(&response_data).expect("Error sending response"); - println!("Response sent."); -} - diff --git a/rust/info.md b/rust/info.md deleted file mode 100644 index 56a4512..0000000 --- a/rust/info.md +++ /dev/null @@ -1,15 +0,0 @@ -Run the example using the command: -``` -cargo run -``` - -Make sure to add the necessary dependencies to your Cargo.toml file: -``` -[dependencies] -serde = { version = "1", features = ["derive"] } -serde_json = "1" -``` - -This example uses the serde and serde_json crates for JSON serialization and deserialization. - - diff --git a/script.js b/script.js new file mode 100644 index 0000000..0272fe5 --- /dev/null +++ b/script.js @@ -0,0 +1,25 @@ +document.addEventListener('DOMContentLoaded', function () { + + const themeToggle = document.getElementById('theme-toggle'); + const toggleIcon = document.getElementById('toggle-icon'); + if(localStorage.getItem('mode')){ + const mode = localStorage.getItem('mode'); + if(mode == "dark"){ + document.body.classList.toggle('dark-theme'); + toggleIcon.classList.toggle('dark-mode'); + toggleIcon.classList.toggle('light-mode'); + themeToggle.click() + } + } + + themeToggle.addEventListener('change', function () { + document.body.classList.toggle('dark-theme'); + toggleIcon.classList.toggle('dark-mode'); + toggleIcon.classList.toggle('light-mode'); + let mode = "light" + if(document.getElementsByClassName('dark-theme')[0]){ + mode = "dark" + } + localStorage.setItem('mode', mode) + }); +}); diff --git a/style.css b/style.css new file mode 100644 index 0000000..cbd6bbe --- /dev/null +++ b/style.css @@ -0,0 +1,232 @@ +:root { + --body-bg-light: #fff; + --nav-bg-light: #ccbcbc; + --body-bg-dark: #123; /* Modify as needed */ + --nav-bg-dark: #234; /* Modify as needed */ +} + +* { + box-sizing: border-box; +} + +html { + font-family: system-ui; +} + +body { + margin: 0; + font-size: 1.25rem; + background: var(--body-bg-light); + padding-inline-start: 20rem; + color: black; + transition: background-color 0.5s ease; +} + +nav { + background: var(--nav-bg-light); + position: fixed; + top: 0; + bottom: 0; + left: 0; + padding-block: 2rem; +} + +.nav-list { + margin: 0; + padding: 0; + list-style: none; + display: grid; + gap: 1rem; +} + +.nav-list a { + color: black; + display: block; + text-decoration: none; +} + +.nav-list li { + padding-block: 1rem; + padding-inline: 2rem; + margin-inline: 1rem 0; +} + +.nav-list li.active { + view-transition-name: nav; + display: block; + background: var(--body-bg-light); + position: relative; + z-index: -1; + border-radius: 100vw 0 0 100vw; +} + +.nav-list li:hover { + background: var(--body-bg-light); +} + +::view-transition-group(nav) { + animation-duration: 1s; +} + +.nav-list li.active::before, +.nav-list li.active::after { + --border-radius: 1rem; + content: ""; + position: absolute; + width: var(--border-radius); + height: var(--border-radius); + right: 0rem; + background: var(--nav-bg-light); +} + +.nav-list li.active::before { + border-radius: 0 0 var(--border-radius); + top: calc(var(--border-radius) * -1); + box-shadow: 5px 5px 0 5px var(--body-bg-light); +} + +.nav-list li.active::after { + border-radius: 0 var(--border-radius) 0 0; + bottom: calc(var(--border-radius) * -1); + box-shadow: 5px -5px 0 5px var(--body-bg-light); +} + +.nav-list li:nth-child(1) a { + view-transition-name: test; +} + +.nav-list li:nth-child(2) a { + view-transition-name: test-2; +} + +.nav-list li:nth-child(3) a { + view-transition-name: test-3; +} + +.switcher { + position: fixed; + top: 20px; + right: 20px; + display: flex; + align-items: center; + z-index: 9999; +} + +.switch { + position: relative; + display: inline-block; + width: 60px; + height: 34px; +} + +.switch input { + opacity: 0; + width: 0; + height: 0; +} + +.slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + transition: .4s; + border-radius: 34px; +} + +.slider:before { + position: absolute; + content: ""; + height: 26px; + width: 26px; + left: 4px; + bottom: 4px; + background-color: white; + transition: .4s; + border-radius: 50%; +} + +input:checked + .slider { + background-color: #2196F3; +} + +input:checked + .slider:before { + transform: translateX(26px); +} + +.round { + border-radius: 34px; +} + +.light-mode { + background-image: url('light-icon.png'); /* Replace with your light mode icon */ +} + +.dark-mode { + background-image: url('dark-icon.png'); /* Replace with your dark mode icon */ +} + +body.dark-theme, body.dark-theme .nav-list li.active{ + background: var(--body-bg-dark); + color: white; +} + +body.dark-theme nav{ + background: var(--nav-bg-dark); + color: white!important; +} +body.dark-theme a{ + color:white +} +body.dark-theme .nav-list li:hover { + background: var(--body-bg-dark); +} +body.dark-theme .nav-list li.active::after, body.dark-theme .nav-list li.active::before{ + + background-color: var(--body-nav-dark); +} +body.dark-theme .nav-list li.active::before { + border-radius: 0 0 var(--border-radius); + top: calc(var(--border-radius) * -1); + box-shadow: 5px 5px 0 5px var(--body-bg-dark); +} + +body.dark-theme .nav-list li.active::after { + border-radius: 0 var(--border-radius) 0 0; + bottom: calc(var(--border-radius) * -1); + box-shadow: 5px -5px 0 5px var(--body-bg-dark); +} +.code{ + background-color: #333; + padding: 3px; + border-radius: 10px; +} +.codeSnippet{ + padding: 16px; + overflow: auto; + font-size: 85%; + line-height: 1.45; + background-color: #333; + color: white; + border-radius: 6px; +} +.content{ + width:95%; +} + +table { + width: 95%; + border-collapse: collapse; +} +table th, table td { + border: 1px solid #ddd; + padding: 8px; +} +table th { + text-align: left; + background-color: #f2f2f2; + color:black +} diff --git a/ts/connect_april.ts b/ts/connect_april.ts deleted file mode 100644 index 8cb80eb..0000000 --- a/ts/connect_april.ts +++ /dev/null @@ -1,36 +0,0 @@ -import * as fs from 'fs'; - -class ConnectApril { - static recv_request(): any | null { - const n: string = process.argv[process.argv.length-1]; - const filePath: string = `.${n}.input`; - - try { - const data: string = fs.readFileSync(filePath, 'utf8'); - return JSON.parse(data); - } catch (err) { - console.error(err); - return null; - } - } - - static send_response(response: any): void { - const n: string = process.argv[process.argv.length-1]; - const filePath: string = `.${n}.output`; - - try { - fs.writeFileSync(filePath, JSON.stringify(response)); - } catch (err) { - console.error(err); - } - } -} - -// Example usage: -//const requestData = ConnectApril.recv_request(); -//console.log('Received data:', requestData); - -//const responseData = { output: 'Hello, World!' }; -//ConnectApril.send_response(responseData); -//console.log('Response sent.'); - diff --git a/ts/example.ts b/ts/example.ts deleted file mode 100644 index eb0289c..0000000 --- a/ts/example.ts +++ /dev/null @@ -1,12 +0,0 @@ -// main.ts - -import { ConnectApril } from './connect_april'; - -// Example usage: -const requestData = ConnectApril.recv_request(); -console.log('Received data:', requestData); - -const responseData = { output: 'Hello, World!' }; -ConnectApril.send_response(responseData); -console.log('Response sent.'); - diff --git a/ts/info.md b/ts/info.md deleted file mode 100644 index 5e34585..0000000 --- a/ts/info.md +++ /dev/null @@ -1,7 +0,0 @@ -Remember to have TypeScript installed (npm install -g typescript) and a tsconfig.json file for configuration if you don't have one already. You can compile the TypeScript code to JavaScript using the tsc command. - - - - - -