filman 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
filman-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Harman Singh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
filman-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: filman
3
+ Version: 0.1.0
4
+ Summary: A Flask-based file management utility
5
+ Author-email: Harman Singh <all.dart603@passinbox.com>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.8
9
+ Requires-Dist: flask>=3.0.0
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Filman
13
+ A Simple Flask File Manager Web App
filman-0.1.0/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # Filman
2
+ A Simple Flask File Manager Web App
@@ -0,0 +1,37 @@
1
+ from flask import Flask,jsonify,render_template,request,url_for
2
+ import os
3
+ #import pathlib as p
4
+ import subprocess
5
+ from .filman import FilMan
6
+ app=Flask(__name__)
7
+ print(os.getcwd())
8
+ fm=FilMan("jjsr")
9
+ form= fm.form
10
+ @app.route("/",methods=["GET","POST"])
11
+ def home():
12
+ nav= fm.Details(fm.File_Struct(os.getcwd()))
13
+ return render_template("index.html",path=os.getcwd(),nav=nav)
14
+ @app.route("/themes")
15
+ def themes():
16
+ return render_template("themes.html")
17
+ @app.route("/windows")
18
+ def js_windows():
19
+ return render_template("jswindows.html")
20
+ @app.route("/file-manager-response",methods=["GET","POST"])
21
+ def file_manager_response():
22
+ try:
23
+ cwd= os.getcwd()
24
+ if request.method=="POST":
25
+ path=request.form["path"]
26
+ nano = request.form["nano"]
27
+ print(f"The output is \033[33m{nano}")
28
+ form["nano"]=fm.FileRead(os.path.join(cwd,path)) if nano== "" else fm.WriteToFile(nano,os.path.join(cwd,path))
29
+ return form["nano"]
30
+ return "No Nano"
31
+ except BaseException as e:
32
+ return str(e)
33
+ def main():
34
+ app.run()
35
+ if __name__=="__main__":
36
+ main()
37
+
@@ -0,0 +1,31 @@
1
+ from flask import Flask,jsonify,render_template,request,url_for
2
+ import os
3
+ import pathlib as p
4
+ import subprocess
5
+ from .filman import FilMan, File_Struct, Details
6
+ app=Flask(__name__)
7
+ print(os.getcwd())
8
+ fm=FilMan("jjsr")
9
+ form= fm.form
10
+ @app.route("/",methods=["GET","POST"])
11
+ def home():
12
+ nav= Details(File_Struct(os.getcwd()))
13
+ return render_template("index.html",path=os.getcwd(),nav=nav)
14
+ @app.route("/themes")
15
+ def themes():
16
+ return render_template("themes.html")
17
+ @app.route("/windows")
18
+ def js_windows():
19
+ return render_template("jswindows.html")
20
+ @app.route("/file-manager-response",methods=["GET","POST"])
21
+ def file_manager_response():
22
+ cwd= os.getcwd()
23
+ if request.method=="POST":
24
+ path=request.form["path"]
25
+ nano = request.form["nano"]
26
+ form["nano"]=fm.FileRead(os.path.join(cwd,path)) if nano== "" else fm.WriteToFile(nano,os.path.join(cwd,path))
27
+ return form["nano"]
28
+ return ""
29
+ if __name__=="__main__":
30
+ app.run(debug=True)
31
+
@@ -0,0 +1,69 @@
1
+ import os
2
+ import tempfile
3
+ import pathlib as p
4
+ import subprocess
5
+ class FilMan:
6
+ def __init__(self,name):
7
+ self.name = name
8
+ self.form={}
9
+
10
+ def FileRead(self,path):
11
+ file_content=""
12
+ if os.path.isfile(path):
13
+ with open(path,"r") as f:
14
+ file_content= f.read()
15
+ return file_content
16
+ def WriteToFile(self,text,path):
17
+ if not os.path.isfile(path):
18
+ return None # Or handle error
19
+
20
+ # 1. Create a temporary file in the same dire>
21
+ dir_name = os.path.dirname(path)
22
+ fd, temp_path = tempfile.mkstemp(dir=dir_name,
23
+ text=True)
24
+
25
+ try:
26
+ with os.fdopen(fd, 'w') as tmp:
27
+ tmp.write(text)
28
+ tmp.flush()
29
+ os.fsync(tmp.fileno()) # Forces the O>
30
+
31
+ # 2. Atomic Rename: This replaces the old>
32
+ # Even if the server crashes now, the old>
33
+ os.replace(temp_path, path)
34
+
35
+ except Exception as e:
36
+ if os.path.exists(temp_path):
37
+ os.remove(temp_path)
38
+ raise e
39
+ return text
40
+ def File_Struct(self,dirs):
41
+ file_struct={}
42
+ a=p.Path(dirs)
43
+ if a.is_file():
44
+ file_struct[a.name]=a.name
45
+ elif a.is_dir():
46
+ for i in a.iterdir():
47
+ file_struct[i.name]=self.File_Struct(i) if i.is_dir() else i.name
48
+ else:
49
+ file_struct[a.name]=a.name
50
+ return file_struct
51
+ def Details(self,files):
52
+ htmlelem=""
53
+ if type(files)==type({}):
54
+ #htmlelem+="<details>"
55
+ for i in files:
56
+ if type(files[i])==type({}):
57
+
58
+ htmlelem+=f"<details data-name='{i}' data-type='folder' >"
59
+ htmlelem+=f"<summary>{i}</summary>"
60
+ htmlelem+=self.Details(files[i])+"</details>"
61
+ else:
62
+ htmlelem+=f"<p data-name='{i}' data-type='file'>{i}</p>"
63
+ #htmlelem+="</details>"
64
+ return htmlelem
65
+ def RunTerminal(self,path,command):
66
+ file_read=""
67
+ with open(path,"r") as f:
68
+ file_read=f.read()
69
+
@@ -0,0 +1,55 @@
1
+ :root{
2
+ --theme-back: black;
3
+ --theme-fore: cyan;
4
+ --theme-border: red;
5
+
6
+ }
7
+ #non-navigation{
8
+ display:flex;
9
+ flex-direction:column;
10
+ align-items:center;
11
+ justify-content:center;
12
+ }
13
+ *{
14
+ font-size:16vw;
15
+ padding:7%;
16
+ border-radius:32vw;
17
+ }
18
+ body{
19
+ display:flex;
20
+ flex-direction:row;
21
+ background:black;
22
+ color:var(--theme-fore);
23
+ text-shadow:2px 2px 4px cyan;
24
+ }
25
+
26
+ .navigation-panel{
27
+ display:flex;
28
+ flex-direction: column;
29
+ gap:3vw;
30
+ padding:10%;
31
+ margin:5px;
32
+ border:2px solid cyan;
33
+ }
34
+ .hide-element{
35
+ display:none;
36
+ /*width:0%;
37
+ overflow:scroll;*/
38
+ }
39
+ #btns{
40
+ display:flex;
41
+ position:sticky;
42
+ top:0%;
43
+ }
44
+ #btns>*{
45
+ background:black;
46
+ border:2px solid var(--theme-fore);
47
+ color:cyan;
48
+ }
49
+ #nano,#terminal{
50
+ background:linear-gradient(cyan,greenyellow);
51
+ border:5px solid var(--theme-fore);
52
+ margin:20px;
53
+
54
+
55
+ }
Binary file
@@ -0,0 +1,107 @@
1
+ [28/02, 6:32 pm] Harmanpreet Singh: ...termux/files/home/FilMan/filman/static/js/script.js
2
+ //alert("hu");
3
+
4
+ let navs=document.querySelectorAll("[data-type='file'>
5
+ let currentpath="";
6
+ let path= document.querySelector("#path");
7
+ let selected =document.querySelector("#selected");
8
+ let nano = document.querySelector("#nano");
9
+ let nav=document.querySelector("#navigation-panel");
10
+ let navBtn= document.querySelector("#nav-btn");
11
+ let saveBtn= document.querySelector("#save-btn");
12
+ let runBtn= document.querySelector("#run-btn");
13
+ navBtn.onclick=function(){
14
+ //alert("hi");
15
+ try{
16
+ nav.classList.toggle("hide-element");
17
+ nav.classList.toggle("navigation-panel")
18
+ }catch(ee){
19
+ alert(ee);
20
+ }
21
+ }
22
+ class FileManagerUI{
23
+ constructor(name){
24
+ this.name=name;
25
+ //this.NanoValue("hi");
26
+ [28/02, 6:47 pm] Harmanpreet Singh: //this.NanoValue("hi");
27
+ }
28
+
29
+
30
+ sayHi(){
31
+ alert("Hi " this.name);
32
+ }
33
+
34
+
35
+ CreateElem(tag,className,value, content,parent){
36
+ let elem= document.createElement(tag);
37
+ elem.classList.add(className);
38
+ elem.setAttribute("value",value);
39
+ elem.innerHTML = content;
40
+ parent.appendChild(elem);
41
+ return elem;
42
+ }
43
+
44
+
45
+ static NanoValue(text){
46
+ //alert(text);
47
+ nano.value= text;
48
+ }
49
+ [28/02, 6:47 pm] Harmanpreet Singh: nano.value= text;
50
+ }
51
+
52
+
53
+ SendAjaxRequest(url,method,data){
54
+ try{
55
+ //let data =[];
56
+ let req=new XMLHttpRequest()
57
+ req.open(method,url)
58
+ req.setRequestHeader("Content-Type",
59
+ "application/x-www-form-urlencoded")
60
+ req.onreadystatechange=function(){
61
+ if(this.readyState==4 && this.status==200){
62
+ //alert(this.responseText);
63
+ FileManagerUI.NanoValue(this.responseText);
64
+ }
65
+
66
+ }
67
+ req.send(data);
68
+ }catch(err){
69
+ alert(err);
70
+ }
71
+ }
72
+ }
73
+ [28/02, 6:49 pm] Harmanpreet Singh: function ReturnPath(elem){
74
+ let path=[];
75
+ while(elem.dataset.name!='navigation'){
76
+ path.unshift(elem.dataset.name);
77
+ elem=elem.parentNode;
78
+ }
79
+ return path.join("/");
80
+ }
81
+
82
+
83
+ function main(){
84
+ try{
85
+ let fm= new FileManagerUI("JJSR");
86
+ for (let i of navs){
87
+ i.addEventListener("click",function(){
88
+ currentpath=ReturnPath(i);
89
+ document.querySelector("#total-path").innerHTML=curre>
90
+ let fd= new FormData();
91
+ fd.append("path",currentpath);
92
+ fd.append("nano",nano.value);
93
+ fm.SendAjaxRequest("{{url_for('file_manager_response'>
94
+ "path="+currentpath+"&nano=");
95
+
96
+ });
97
+ [28/02, 6:49 pm] Harmanpreet Singh: });
98
+ }
99
+ saveBtn.addEventListener("click",function(){
100
+ fm.SendAjaxRequest("{{url_for('file_manager_response'>
101
+ "path="+currentpath+"&nano="+nano.value);
102
+ });
103
+ }catch(e){
104
+ alert(e);
105
+ }
106
+ }
107
+ main();
@@ -0,0 +1,105 @@
1
+ let navs=document.querySelectorAll("[data-type='file']");
2
+ let currentpath="";
3
+ let path= document.querySelector("#path");
4
+ let selected =document.querySelector("#selected");
5
+ let nano = document.querySelector("#nano");
6
+ let terminal = document.querySelector("#terminal");
7
+ let nav=document.querySelector("#navigation-panel");
8
+ let navBtn= document.querySelector("#nav-btn");
9
+ let saveBtn= document.querySelector("#save-btn");
10
+ let runBtn= document.querySelector("#run-btn");
11
+ navBtn.onclick=function(){
12
+ //alert("hi");
13
+ try{
14
+ nav.classList.toggle("hide-element");
15
+ nav.classList.toggle("navigation-panel");
16
+ }catch(ee){
17
+ alert(ee);
18
+ }
19
+ }
20
+
21
+ class FileManagerUI{
22
+ constructor(name){
23
+ this.name=name;
24
+ }
25
+
26
+
27
+ sayHi(){
28
+ alert("Hi "+this.name);
29
+ }
30
+
31
+
32
+ CreateElem(tag,className,value, content,parent){
33
+ let elem= document.createElement(tag);
34
+ elem.classList.add(className);
35
+ elem.setAttribute("value",value);
36
+ elem.innerHTML = content;
37
+ parent.appendChild(elem);
38
+ return elem;
39
+ }
40
+
41
+
42
+ static NanoValue(text){
43
+ //alert(text);
44
+ nano.value= text;
45
+ }
46
+
47
+
48
+ SendAjaxRequest(url,method,data){
49
+ try{
50
+ //let data =[];
51
+ let req=new XMLHttpRequest();
52
+ req.open(method,url);
53
+ req.setRequestHeader("Content-Type",
54
+ "application/x-www-form-urlencoded");
55
+ req.onreadystatechange=function(){
56
+ if(this.readyState==4 && this.status==200){
57
+ //alert(this.responseText);
58
+ FileManagerUI.NanoValue(this.responseText);
59
+ }
60
+
61
+ }
62
+ req.send(data);
63
+ }catch(err){
64
+ alert(err);
65
+ }
66
+ }
67
+ }
68
+
69
+ function ReturnPath(elem){
70
+ let path=[];
71
+ while(elem.dataset.name!='navigation'){
72
+ path.unshift(elem.dataset.name);
73
+ elem=elem.parentNode;
74
+ }
75
+ return path.join("/");
76
+ }
77
+
78
+
79
+ function main(){
80
+ try{
81
+ let fm= new FileManagerUI("JJSR");
82
+ for (let i of navs){
83
+ i.addEventListener("click",function(){
84
+ currentpath=ReturnPath(i);
85
+ document.querySelector("#total-path").innerHTML=currentpath
86
+ let fd= new FormData();
87
+ fd.append("path",currentpath);
88
+ fd.append("nano",nano.value);
89
+ fm.SendAjaxRequest(MyConstants["url"],
90
+ MyConstants["method"],
91
+ "path="+currentpath+"&nano=");
92
+
93
+ });
94
+ }
95
+ saveBtn.addEventListener("click",function(){
96
+ fm.SendAjaxRequest(MyConstants["url"],
97
+ MyConstants["method"],
98
+ "path="+currentpath+"&nano="+nano.value);
99
+ });
100
+ }catch(e){
101
+ alert(e);
102
+ }
103
+ }
104
+ main();
105
+
@@ -0,0 +1,43 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>File Manager</title>
8
+ <link rel="stylesheet" href="{{url_for('static',filename='css/style.css')}}">
9
+ </link>
10
+ </head>
11
+ <body>
12
+ <!-- JAI JAI SIYA RAM! -->
13
+ <div id="navigation-panel" data-name='navigation' data-type='nav' class="hide-element">
14
+ {{nav | safe}}</div>
15
+ <div id="non-navigation">
16
+ <div id="btns">
17
+ <button id="nav-btn">Toggle Navigation</button>
18
+ <button id="save-btn">Save</button>
19
+ <button id="run-btn">Run</button></div>
20
+ <form method="POST">
21
+ <h1 id="cwd" >{{path}}/<span id="total-path"></span></h1>
22
+ <!--<input id="path" name="path" type="url" />
23
+ <div><select id="selected" name="selected">
24
+ </select>
25
+ </div>-->
26
+ <textarea id="nano" name="nano" rows="40" cols="40">
27
+ </textarea>
28
+ <textarea id="terminal" name="terminal" rows="40" cols="40">
29
+ </textarea>
30
+ </form></div><script>
31
+
32
+ window.MyConstants={
33
+ "url":"{{url_for('file_manager_response')}}",
34
+ "method":"POST"
35
+ }
36
+ </script>
37
+ <script
38
+ src="{{url_for('static',filename='js/script.js')}}"
39
+ defer >
40
+ </script>
41
+ </body>
42
+ </html>
43
+
@@ -0,0 +1,62 @@
1
+ <html>
2
+
3
+ <head>
4
+
5
+ <title>JS Window</title>
6
+
7
+
8
+ </head>
9
+
10
+ <body>
11
+
12
+
13
+ <script defer>
14
+ function CreateElement(tagName,className,content,parent){
15
+ let elem=document.createElement(tagName);
16
+ elem.classList.add(className);
17
+ elem.innerHTML=content;
18
+ parent.appendChild(elem);
19
+ return elem;
20
+ }
21
+ let i=0;
22
+ function ExpandAll(ob){
23
+ i+=1;
24
+ //alert(i);
25
+ try{
26
+ let elem="";
27
+ if(i>2500){
28
+ return elem;
29
+ }
30
+ for(let i in ob){
31
+
32
+ if(typeof(ob[i])==typeof({})){
33
+ elem+="<h1><details><summary> "+i+"</summary> === ";
34
+ elem+=ExpandAll(ob[i])+" </details></h1>";
35
+ }else{
36
+ elem+="<h3> "+i+" === "+ob[i]+" h3</h3>"
37
+ }
38
+ }
39
+ return elem;
40
+ }catch(err){
41
+ alert(err);
42
+ }
43
+ }
44
+ function main(){
45
+ try{
46
+ alert(document.body.parentNode.innerHTML)
47
+ //alert(dir(geolocation.clearWatch()));
48
+ CreateElement("div","window",ExpandAll(document.body.parentNode.childNodes),
49
+ document.body);
50
+ CreateElement("div","window",Object.keys(window),
51
+ document.body);
52
+
53
+ }catch(err){
54
+ alert(err+" ++ "+typeof(err));
55
+ }
56
+ }
57
+
58
+ main();
59
+
60
+ </script>
61
+ </body>
62
+ </html>
@@ -0,0 +1,105 @@
1
+ <html>
2
+
3
+ <head>
4
+
5
+ <title>Select Theme</title>
6
+
7
+
8
+ </head>
9
+
10
+ <body>
11
+ <form>
12
+ <!--<input id="backg-text-input" type="text" placeholder="Enter Background color code" />
13
+ --><input id="backg-color-input" type="color" placeholder="Select Background Color" />
14
+ </br>
15
+ <!--<input id="foreg-text-input" type="text" placeholder="Enter Foreground Color Code" />
16
+ --><input id="foreg-color-input" type="color" />
17
+
18
+ <script>
19
+ let backgText=document.querySelector("#backg-text-input");
20
+ let backgColor=document.querySelector("#backg-color-input");
21
+ let foregText=document.querySelector("#foreg-text-input");
22
+ let foregColor=document.querySelector("#foreg-color-input");
23
+
24
+
25
+
26
+ function CreateElement(tagName,content,className,attributes,parent){
27
+ let elem = document.createElement(tagName);
28
+ elem.innerHTML=content;
29
+ elem.classList.add(className);
30
+ for(let i in attributes){
31
+ elem.setAttribute(i,attributes[i]);
32
+ }
33
+ parent.appendChild(elem);
34
+ return elem;
35
+ }
36
+
37
+ function ColorCode(n){
38
+ let code="#";
39
+ let ns=""+n;
40
+ for(let i=0;i<4-ns.length;i++){
41
+ code+="0";
42
+ }
43
+ code+=ns;
44
+ return code;
45
+ }
46
+
47
+
48
+
49
+ function AddBackgroundColor(elem){
50
+ //alert(elem.value);
51
+ document.body.style.background=elem.value;
52
+ }
53
+
54
+ function DecToHex(n){
55
+ let b=""
56
+ let he=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]
57
+ while (n!=0){
58
+ //alert(n);
59
+ b+=he[(n%16)];
60
+ n=Math.floor(n/16);
61
+ }
62
+ //alert(b);
63
+ let c=""
64
+ for(let i=b.length-1;i>-1;i--){
65
+ c+=b[i];
66
+ }
67
+ return c;
68
+ }
69
+
70
+ function main(){
71
+ try{
72
+ alert(DecToHex(Number(prompt("Enter No."))));
73
+ let elem0= CreateElement("h1","Jai Jai Siya Ram!",
74
+ "color-code",{},document.body);
75
+ elem0.style.position="sticky";
76
+ elem0.style.top="0%";
77
+
78
+
79
+ backgColor.onchange=function(){
80
+ AddBackgroundColor(backgColor);
81
+
82
+ }
83
+ foregColor.onchange=function(){
84
+ elem0.style.color=foregColor.value;
85
+ }
86
+
87
+ for(let i =0;i<10000;i++){
88
+ let elem= CreateElement("div",i,
89
+ "color-code",{},document.body);
90
+ elem.style.background=ColorCode(i);
91
+ elem.onclick=function(){
92
+ elem0.style.color = ColorCode(i);
93
+ alert(ColorCode(i));
94
+ }
95
+ }
96
+
97
+
98
+ }catch(err){
99
+ alert(err);
100
+ }
101
+ }
102
+ main();
103
+ </script>
104
+ </body>
105
+ </html>
@@ -0,0 +1,28 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "filman"
7
+ version = "0.1.0"
8
+ description = "A Flask-based file management utility"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Harman Singh", email = "all.dart603@passinbox.com"},
14
+ ]
15
+ dependencies = [
16
+ "Flask>=3.0.0",
17
+ ]
18
+
19
+ [project.scripts]
20
+ filman = "filman:main"
21
+
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["filman"]
24
+
25
+ # We only use 'artifacts' if files are outside the package.
26
+ # Since your static/templates are INSIDE 'filman/',
27
+ # the 'packages' setting above already handles them.
28
+