Skip to content

Commit 4775297

Browse files
committed
First proj
0 parents  commit 4775297

28 files changed

+2218
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
venv/
2+
.idea/
3+
*.pyc
4+
*.pyo
5+
*.pyd
6+
7+
8+
9+
10+
11+
/venv/
12+
/.idea/

CONTRIBUTING.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Contributing to RollAsBack
2+
3+
Welcome to RollAsBack! We appreciate your interest in contributing to this project. Whether you're fixing a bug,
4+
improving an existing feature, or adding a new one, your contribution is valuable.
5+
6+
## Getting Started
7+
8+
Before you start contributing, please ensure you have read the [README](README.md) file to understand the project
9+
structure and how to use RollAsBack.
10+
11+
## How to Contribute
12+
13+
1. **Fork the Repository:**
14+
- Click on the "Fork" button at the top right of
15+
the [main repository page](https://github.com/your-username/rollasback) to create your fork.
16+
17+
2. **Clone Your Fork:**
18+
- Clone your forked repository to your local machine.
19+
```bash
20+
git clone https://github.com/your-username/rollasback.git
21+
```
22+
23+
3. **Create a Branch:**
24+
- Create a new branch for your contribution.
25+
```bash
26+
git checkout -b feature/my-feature
27+
```
28+
29+
4. **Make Changes:**
30+
- Make your changes to the codebase. Ensure that your changes follow the project's coding conventions.
31+
32+
5. **Run Tests:**
33+
- Before submitting a pull request, run the tests to ensure that your changes do not break existing functionality.
34+
35+
6. **Commit Changes:**
36+
- Commit your changes with a meaningful commit message.
37+
```bash
38+
git commit -m "Add new feature"
39+
```
40+
41+
7. **Push Changes:**
42+
- Push your changes to your fork on GitHub.
43+
```bash
44+
git push origin feature/my-feature
45+
```
46+
47+
8. **Create a Pull Request:**
48+
- Go to your fork on GitHub and open a pull request.
49+
- Provide a detailed description of your changes and why they are necessary.
50+
51+
## Code Review
52+
53+
Your pull request will be reviewed by the project maintainers. During the review process, you may be asked to make
54+
additional changes. Once your pull request is approved, it will be merged into the main branch.
55+
56+
## Reporting Issues
57+
58+
If you encounter bugs or have suggestions for improvements,
59+
please [open an issue](https://github.com/your-username/rollasback/issues) on GitHub. Provide detailed information about
60+
the issue or your suggestion.
61+
62+
## Code of Conduct
63+
64+
Please note that RollAsBack has a [Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project, you agree to
65+
abide by its terms.
66+
67+
Thank you for contributing to RollAsBack! Your efforts help make this project better for everyone.

LISENCE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 CodeWiki
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.

MANIFEST.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include README.md
2+
include LICENSE
3+
include CONTRIBUTING.md
4+
include CHANGELOG.md
5+
include /markdowns/*
6+
include /tests/*

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# RollAsBack - Python Web Backend Framework
2+
3+
**Author(s):** CodeWiki
4+
5+
**File Name:** rest_endpoint.py
6+
7+
**Date:** 16th January 2024
8+
9+
## Description
10+
11+
RollAsBack is a web backend framework written in Python. It is designed to provide a simple and flexible solution for building web applications. This framework allows you to define routes and handle HTTP requests efficiently.
12+
13+
## Disclaimer
14+
15+
This 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.
16+
17+
## Copyright
18+
19+
Copyright @ CodeWiki by MIT License
20+
21+
## Usage
22+
23+
RollAsBack provides a simple way to define and handle routes in your web application. It includes basic functionality for handling HTTP requests and responses.
24+
25+
## Features
26+
27+
- **Route Handling:** Define routes using the `@endpoint` decorator.
28+
- **Request Parsing:** Parse HTTP requests and extract relevant information.
29+
- **Response Generation:** Generate HTTP responses with ease.
30+
- **Logging:** Log important events and messages.
31+
32+
## Example
33+
34+
```python
35+
from src.rollasback import RollAsBack, HttpResponse, RESPONSEMEMETYPES
36+
37+
app = RollAsBack("MyApp")
38+
39+
40+
@app.endpoint("/hello")
41+
def hello(request):
42+
return HttpResponse("Hello, World!", status=200, mimetype=RESPONSEMEMETYPES.text_plain)
43+
44+
45+
if __name__ == "__main__":
46+
app.start_server("127.0.0.1", 8000)
47+
```
48+
49+
In this example, a simple "Hello, World!" route is defined. When the server is started, it listens on `127.0.0.1:8000` for incoming requests.
50+
51+
## License
52+
53+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
54+
55+
---
56+
57+
*Note: Adjust the file structure and import paths according to your project setup.*
58+
59+
Feel free to extend RollAsBack based on your application's requirements. For more details on how to use and customize the framework, refer to the source code and additional documentation.
60+
61+
**Happy coding with RollAsBack!**

markdowns/cookie.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
## Cookie Class Documentation
2+
3+
### Class: `Cookie`
4+
5+
#### Constructor: `__init__(self, key, value, expires=None, path=None, domain=None, secure=False, httponly=False)`
6+
7+
- **Parameters:**
8+
- `key` (str): The key of the cookie.
9+
- `value` (str): The value of the cookie.
10+
- `expires` (str, optional): The expiration date and time of the cookie in string format. Defaults to `None`.
11+
- `path` (str, optional): The path to which the cookie is applicable. Defaults to `None`.
12+
- `domain` (str, optional): The domain to which the cookie is applicable. Defaults to `None`.
13+
- `secure` (bool, optional): Indicates if the cookie should only be sent over secure connections. Defaults to `False`.
14+
- `httponly` (bool, optional): Indicates if the cookie is accessible only through HTTP requests and not through JavaScript. Defaults to `False`.
15+
16+
#### Method: `__str__(self)`
17+
18+
- **Returns:**
19+
- `str`: A string representation of the cookie suitable for HTTP headers.
20+
21+
#### Method: `__repr__(self)`
22+
23+
- **Returns:**
24+
- `str`: A string representation of the cookie, equivalent to calling `str(self)`.
25+
26+
#### Method: `__eq__(self, other)`
27+
28+
- **Parameters:**
29+
- `other` (Cookie): Another cookie object to compare with.
30+
31+
- **Returns:**
32+
- `bool`: `True` if both cookies have the same key and value, `False` otherwise.
33+
34+
#### Method: `__hash__(self)`
35+
36+
- **Returns:**
37+
- `int`: Hash value of the cookie based on its key.
38+
39+
#### Method: `__setattr__(self, key, value)`
40+
41+
- **Parameters:**
42+
- `key` (str): The attribute key.
43+
- `value` (various): The value to be set.
44+
45+
- **Raises:**
46+
- `TypeError`: If the provided value is not of the expected type for the corresponding attribute.
47+
48+
#### Method: `__getattr__(self, key)`
49+
50+
- **Parameters:**
51+
- `key` (str): The attribute key.
52+
53+
- **Returns:**
54+
- Various: The value of the requested attribute.
55+
56+
- **Raises:**
57+
- `AttributeError`: If the requested attribute is not available.
58+
59+
#### Method: `__delattr__(self, key)`
60+
61+
- **Parameters:**
62+
- `key` (str): The attribute key.
63+
64+
- **Raises:**
65+
- `AttributeError`: If the requested attribute is not deletable.
66+
67+
#### Method: `__contains__(self, key)`
68+
69+
- **Parameters:**
70+
- `key` (str): The attribute key.
71+
72+
- **Returns:**
73+
- `bool`: `True` if the key exists as an attribute, `False` otherwise.
74+
75+
### Class: `CookieJar`
76+
77+
#### Constructor: `__init__(self)`
78+
79+
- **Attributes:**
80+
- `cookies` (list): A list to store `Cookie` objects.
81+
82+
#### Method: `add_cookie(self, cookie)`
83+
84+
- **Parameters:**
85+
- `cookie` (Cookie): The `Cookie` object to add to the jar.
86+
87+
#### Method: `__str__(self)`
88+
89+
- **Returns:**
90+
- `str`: A string representation of all cookies in the jar.
91+
92+
#### Method: `get_cookie(self, key)`
93+
94+
- **Parameters:**
95+
- `key` (str): The key of the cookie to retrieve.
96+
97+
- **Returns:**
98+
- `Cookie` or `None`: The cookie object if found, otherwise `None`.
99+
100+
#### Method: `get_cookies(self)`
101+
102+
- **Returns:**
103+
- `list`: A list of all cookies in the jar.
104+
105+
#### Method: `get_cookie_string(self)`
106+
107+
- **Returns:**
108+
- `str`: A string representation of all cookies in the jar suitable for HTTP headers.
109+
110+
#### Method: `delete_cookie(self, key)`
111+
112+
- **Parameters:**
113+
- `key` (str): The key of the cookie to delete.
114+
115+
- **Returns:**
116+
- `bool`: `True` if the cookie was deleted, `False` otherwise.
117+
118+
#### Method: `delete_cookies(self)`
119+
120+
- **Description:**
121+
- Clears all cookies from the jar.
122+
123+
#### Method: `update_cookie(self, cookie)`
124+
125+
- **Parameters:**
126+
- `cookie` (Cookie): The updated `Cookie` object.
127+
128+
- **Returns:**
129+
- `bool`: `True` if the cookie was updated, `False` otherwise.
130+
131+
#### Method: `set_cookie(self, key, value, expires=None, path=None, domain=None, secure=False, httponly=False)`
132+
133+
- **Parameters:**
134+
- Same as the `Cookie` constructor.
135+
136+
- **Description:**
137+
- Creates a new `Cookie` object and updates it in the jar.
138+
139+
#### Method: `set_cookies(self, cookies)`
140+
141+
- **Parameters:**
142+
- `cookies` (list): A list of `Cookie` objects to update in the jar.
143+
144+
#### Method: `get_cookie_header(self)`
145+
146+
- **Returns:**
147+
- `str`: A string representation of all cookies in the jar suitable for HTTP headers.
148+
149+
#### Method: `get_cookie_dict(self)`
150+
151+
- **Returns:**
152+
- `dict`: A dictionary mapping cookie keys to their values.

0 commit comments

Comments
 (0)