termido 0.1.0__py3-none-any.whl

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.
termido/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ from .core import log, new, help
2
+ from .__version__ import __version__
termido/__version__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
termido/auth.py ADDED
@@ -0,0 +1,24 @@
1
+ import requests
2
+
3
+ LOGIN_API = "https://termid.free.nf/api/login.php"
4
+
5
+ class Session:
6
+ def __init__(self, username: str, api_key: str):
7
+ self.username = username
8
+ self.api_key = api_key
9
+
10
+ def login(api_key: str) -> Session:
11
+ if not api_key or len(api_key) < 10:
12
+ raise ValueError("Invalid API key")
13
+
14
+ r = requests.post(
15
+ LOGIN_API,
16
+ json={"api_key": api_key},
17
+ timeout=10
18
+ )
19
+
20
+ if r.status_code != 200:
21
+ raise RuntimeError("Login failed. Check API key.")
22
+
23
+ data = r.json()
24
+ return Session(username=data["username"], api_key=api_key)
termido/core.py ADDED
@@ -0,0 +1,27 @@
1
+ from .auth import login
2
+ from .project import Project
3
+
4
+ _session = None
5
+
6
+ def log(api_key: str):
7
+ global _session
8
+ _session = login(api_key)
9
+ return True
10
+
11
+ def new(name: str):
12
+ if _session is None:
13
+ raise RuntimeError("Please login first using termido.log(API_KEY)")
14
+ return Project(_session, name)
15
+
16
+ def help():
17
+ print("""
18
+ TERMIDO – Beginner Usage
19
+
20
+ termido.log("API_KEY")
21
+
22
+ p = termido.new("project_name")
23
+ p.add("index.html", "<h1>Hello</h1>")
24
+ p.add("app.js", "alert('Hi')")
25
+ p.go()
26
+ p.open()
27
+ """)
termido/project.py ADDED
@@ -0,0 +1,50 @@
1
+ import requests
2
+ import webbrowser
3
+ from .utils import check_file
4
+
5
+ PUBLISH_API = "https://termid.free.nf/api/publish.php"
6
+
7
+ class Project:
8
+ def __init__(self, session, name: str):
9
+ if not name:
10
+ raise ValueError("Project name required")
11
+
12
+ self.session = session
13
+ self.name = name
14
+ self.files = {}
15
+ self.url = None
16
+
17
+ def add(self, file: str, content: str):
18
+ check_file(file, content)
19
+ self.files[file] = content
20
+
21
+ def clear(self):
22
+ self.files = {}
23
+
24
+ def go(self):
25
+ if "index.html" not in self.files:
26
+ raise RuntimeError("index.html is required")
27
+
28
+ payload = {
29
+ "username": self.session.username,
30
+ "api_key": self.session.api_key,
31
+ "project": self.name,
32
+ "files": self.files
33
+ }
34
+
35
+ r = requests.post(
36
+ PUBLISH_API,
37
+ json=payload,
38
+ timeout=20
39
+ )
40
+
41
+ if r.status_code != 200:
42
+ raise RuntimeError("Publish failed")
43
+
44
+ self.url = r.json()["url"]
45
+ return self.url
46
+
47
+ def open(self):
48
+ if not self.url:
49
+ raise RuntimeError("Run go() before open()")
50
+ webbrowser.open(self.url)
termido/utils.py ADDED
@@ -0,0 +1,12 @@
1
+ ALLOWED_EXT = (".html", ".css", ".js", ".json", ".png", ".jpg", ".jpeg")
2
+ MAX_SIZE = 500_000 # 200 KB
3
+
4
+ def check_file(filename: str, content: str):
5
+ if not filename.endswith(ALLOWED_EXT):
6
+ raise ValueError("This file type is not allowed")
7
+
8
+ if not isinstance(content, str):
9
+ raise ValueError("File content must be text")
10
+
11
+ if len(content) > MAX_SIZE:
12
+ raise ValueError("File is too large (max 200KB)")
@@ -0,0 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: termido
3
+ Version: 0.1.0
4
+ Summary: Beginner-friendly Python library to publish HTML, CSS and JavaScript projects online
5
+ Author: Shubham
6
+ License: MIT
7
+ Project-URL: Homepage, https://yourdomain.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Intended Audience :: Education
12
+ Classifier: Topic :: Internet :: WWW/HTTP
13
+ Classifier: Topic :: Education
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: requests>=2.25
18
+ Dynamic: license-file
19
+
20
+ # Termido
21
+
22
+ Termido lets beginners publish HTML, CSS, and JavaScript projects online using Python.
23
+
24
+ ## Install
25
+ ```bash
26
+ pip install termido
@@ -0,0 +1,11 @@
1
+ termido/__init__.py,sha256=96PS3eFUfvNdC9iMzt_ElpFzOJ-imM0FO7gWN4pJ0bA,69
2
+ termido/__version__.py,sha256=Pru0BlFBASFCFo7McHdohtKkUtgMPDwbGfyUZlE2_Vw,21
3
+ termido/auth.py,sha256=IgUnNrpAdIoVbGj2o88Nz6T7z-70epxYd_cU3VzQ0iA,598
4
+ termido/core.py,sha256=4BEaG8v4XuB58TRZAerSrpVE6qRaNsIuDEQ6zhoAzFo,517
5
+ termido/project.py,sha256=ysfGMYgrwfGtAzDO-dxZee9emi3IvW-nukNQy6YlXwo,1220
6
+ termido/utils.py,sha256=gCC5bFlxm5TuULiQ9VP6AqbgLkaw4k9haaIvDiOM-Vo,432
7
+ termido-0.1.0.dist-info/licenses/LICENSE,sha256=OPVfJu0iA9d6lS94CrFzex8yK3HNwlRFaJRISnUoFPA,1063
8
+ termido-0.1.0.dist-info/METADATA,sha256=WB8qNekSZIXN7gF3LJpI8xTNC935lgD4kAMcPMxwRHY,767
9
+ termido-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
+ termido-0.1.0.dist-info/top_level.txt,sha256=jOhVdrS4lZHjdrAG-wD7TC8rLtitGtGhUMgyv3Lmxkw,8
11
+ termido-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.10.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shubham
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.
@@ -0,0 +1 @@
1
+ termido