{"id":29075297,"url":"https://github.com/lcfhershell/piesharkx","last_synced_at":"2025-06-27T15:30:33.177Z","repository":{"id":299048559,"uuid":"1001915176","full_name":"LcfherShell/piesharkx","owner":"LcfherShell","description":"Micro Framework for Human","archived":false,"fork":false,"pushed_at":"2025-06-14T10:31:00.000Z","size":784,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"v0.1.0","last_synced_at":"2025-06-14T11:24:39.975Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LcfherShell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-14T10:06:21.000Z","updated_at":"2025-06-14T10:15:40.000Z","dependencies_parsed_at":"2025-06-14T11:34:57.461Z","dependency_job_id":null,"html_url":"https://github.com/LcfherShell/piesharkx","commit_stats":null,"previous_names":["lcfhershell/piesharkx"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/LcfherShell/piesharkx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LcfherShell%2Fpiesharkx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LcfherShell%2Fpiesharkx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LcfherShell%2Fpiesharkx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LcfherShell%2Fpiesharkx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LcfherShell","download_url":"https://codeload.github.com/LcfherShell/piesharkx/tar.gz/refs/heads/v0.1.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LcfherShell%2Fpiesharkx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262281555,"owners_count":23286862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-27T15:30:30.627Z","updated_at":"2025-06-27T15:30:33.112Z","avatar_url":"https://github.com/LcfherShell.png","language":"Python","readme":"# 🦈 PieShark Framework\n*A Lightweight, Powerful Python Web Framework*\n\n---\n\n## 🚀 Overview\n\n**PieShark** is a modern, lightweight WSGI-based Python web framework designed for developers who want power without complexity. Built with performance and security in mind, it offers everything you need to create robust web applications and APIs.\n\n### ✨ Key Features\n\n- 🛣️ **Flexible Routing** - Path parameters, regex patterns, and RESTful endpoints\n- 🔐 **Built-in Security** - Automatic session and cookie encryption\n- 🧩 **Modular Design** - Blueprint system for organized code architecture\n- ⚡ **Async/Sync Support** - Native support for both synchronous and asynchronous handlers\n- 🎨 **Simple Templating** - Lightweight template engine with Python variable injection\n- 🔧 **Middleware Ready** - Custom middleware support for request/response processing\n- 📦 **Static File Serving** - Built-in static file handling\n\n---\n\n## 🏁 Quick Start\n\n### Installation \u0026 Setup\n\n```python\nfrom PieShark.main import pieshark, request, form, session\nfrom PieShark.blueprint import Blueprint\nfrom PieShark.session import SESSION\nfrom PieShark.cookie import Cookie\nfrom PieShark.templates import Templates\nfrom PieShark.pydejs import PY_deJS\n\n# Initialize your application\napp = pieshark(debug=True)\n\n# Configure your app\napp.config.update({\n    'secret_key': 'your-super-secret-key-here',\n    'session_permanent': True,\n    'url_dbase': 'base://sqlite3:static',\n    'limit_size_upload': 3089003  # ~3MB upload limit\n})\n```\n\n### Your First Route\n\n```python\n@app.route(\"/\")\nasync def home():\n    session['user'] = 'Developer'\n    return Templates(\n        \"\u003ch1\u003eWelcome to {{ framework }}!\u003c/h1\u003e\", \n        framework=\"PieShark\"\n    )\n\n@app.route(\"/api/user/{user_id}\")\nasync def get_user(user_id):\n    return app.json_response({\n        \"user_id\": user_id,\n        \"status\": \"active\"\n    })\n```\n\n---\n\n## 🛣️ Advanced Routing\n\nPieShark supports multiple routing patterns to fit your application's needs:\n\n### Dynamic Parameters\n```python\n@app.route(\"/users/{user_id}/posts/{post_id}\")\nasync def get_user_post(user_id, post_id):\n    return f\"User {user_id}, Post {post_id}\"\n```\n\n### HTTP Methods\n```python\n@app.route(\"/api/data\", methods=[\"GET\", \"POST\", \"PUT\", \"DELETE\"])\nasync def handle_data():\n    if request.method == \"POST\":\n        # Handle POST data\n        return app.json_response({\"created\": True})\n    elif request.method == \"GET\":\n        # Handle GET request\n        return app.json_response({\"data\": \"sample\"})\n```\n\n---\n\n## 🔐 Security Features\n\n### Session Management\n```python\n@app.route(\"/login\", methods=[\"POST\"])\nasync def login():\n    # Sessions are automatically encrypted\n    session['user_id'] = 12345\n    session['username'] = 'john_doe'\n    session['roles'] = ['user', 'admin']\n    return app.redirect(\"/dashboard\")\n\n@app.route(\"/dashboard\")\nasync def dashboard():\n    if not session.get('user_id'):\n        return app.abort(401)\n    return f\"Welcome back, {session['username']}!\"\n```\n\n### Encrypted Cookies\n```python\n# Initialize cookie handler with custom salt\ncookie = Cookie(salt=\"your_custom_salt\", app=app)\n\n@app.route(\"/set-preference\")\nasync def set_preference():\n    # Cookies are automatically encrypted\n    cookie.create(\"theme=dark\u0026lang=en\")\n    return \"Preferences saved!\"\n\n@app.route(\"/get-preference\")\nasync def get_preference():\n    # Decrypt and read cookie data\n    theme = cookie.select.theme.decode()\n    return f\"Current theme: {theme}\"\n```\n\n---\n\n## 🧩 Modular Architecture with Blueprints\n\nOrganize your application into logical modules:\n\n```python\n# auth_blueprint.py\nauth_bp = Blueprint('auth', url_prefix='/auth')\n\n@auth_bp.route('/login', methods=['GET', 'POST'])\nasync def login():\n    if request.method == 'POST':\n        username = form.username.decode()\n        password = form.password.decode()\n        \n        # Your authentication logic here\n        if authenticate(username, password):\n            session['user'] = username\n            return app.redirect('/dashboard')\n    \n    return Templates(\"\"\"\n        \u003cform method=\"post\"\u003e\n            \u003cinput name=\"username\" type=\"text\" placeholder=\"Username\" required\u003e\n            \u003cinput name=\"password\" type=\"password\" placeholder=\"Password\" required\u003e\n            \u003cbutton type=\"submit\"\u003eLogin\u003c/button\u003e\n        \u003c/form\u003e\n    \"\"\")\n\n@auth_bp.route('/logout')\nasync def logout():\n    session.clear()\n    return app.redirect('/')\n\n# Register blueprint in main app\napp.register_blueprint(auth_bp)\n```\n\n---\n\n## 🎨 Template System\n\n### Inline Templates\n```python\n@app.route(\"/profile/{username}\")\nasync def profile(username):\n    user_data = get_user_data(username)  # Your data fetching logic\n    \n    return Templates(\"\"\"\n        \u003cdiv class=\"profile\"\u003e\n            \u003ch1\u003e{{ user.name }}\u003c/h1\u003e\n            \u003cp\u003eEmail: {{ user.email }}\u003c/p\u003e\n            \u003cp\u003eJoined: {{ user.join_date }}\u003c/p\u003e\n        \u003c/div\u003e\n    \"\"\", user=user_data)\n```\n\n### File-based Templates\n```python\n# For larger templates, use external files\n@app.route(\"/complex-page\")\nasync def complex_page():\n    return Templates(\"complex_template.shark\", \n                    title=\"My App\",\n                    data=fetch_page_data())\n```\n\n---\n\n## 📁 Static File Handling\n\n```python\n# Serve static files\napp.static(\"static/\", \"/static/\")\napp.static(\"uploads/\", \"/files/\")\n\n# Now accessible at:\n# /static/style.css -\u003e static/style.css\n# /files/document.pdf -\u003e uploads/document.pdf\n```\n\n---\n\n## 📤 Form Processing \u0026 File Uploads\n\n```python\n@app.route(\"/upload\", methods=[\"GET\", \"POST\"])\nasync def upload_file():\n    if request.method == \"POST\":\n        # Access form data (automatically encrypted)\n        title = form.title.decode()\n        description = form.description.decode()\n        \n        # Handle file uploads\n        uploaded_file = form.file  # File object\n        if uploaded_file:\n            filename = secure_filename(uploaded_file.filename)\n            ///Logic your saving file\n        \n        return app.json_response({\n            \"status\": \"success\",\n            \"title\": title,\n            \"filename\": filename\n        })\n    \n    return Templates(\"\"\"\n        \u003cform method=\"post\" enctype=\"multipart/form-data\"\u003e\n            \u003cinput name=\"title\" type=\"text\" placeholder=\"Title\" required\u003e\n            \u003ctextarea name=\"description\" placeholder=\"Description\"\u003e\u003c/textarea\u003e\n            \u003cinput name=\"file\" type=\"file\" required\u003e\n            \u003cbutton type=\"submit\"\u003eUpload\u003c/button\u003e\n        \u003c/form\u003e\n    \"\"\")\n```\n\n---\n\n## 🔄 Middleware \u0026 Hooks\n\n### Request Lifecycle Hooks\n```python\n@app.before_request\ndef authenticate_user():\n    \"\"\"Run before every request\"\"\"\n    if request.path.startswith('/admin/'):\n        if not session.get('is_admin'):\n            return app.abort(403)\n\n@app.after_request\ndef add_security_headers(response):\n    \"\"\"Run after every request\"\"\"\n    response.headers['X-Content-Type-Options'] = 'nosniff'\n    response.headers['X-Frame-Options'] = 'DENY'\n    return response\n```\n\n### Custom Middleware\n```python\nclass RequestTimingMiddleware:\n    def __init__(self, app):\n        self.app = app\n    \n    def __call__(self, environ, start_response):\n        start_time = time.time()\n        response = self.app(environ, start_response)\n        end_time = time.time()\n        \n        print(f\"Request took {end_time - start_time:.2f}s\")\n        return response\n\n# Apply middleware\napp.wsgi_app = RequestTimingMiddleware(app.wsgi_app)\n```\n\n---\n\n## 🌐 API Development\n\n### RESTful API Example\n```python\napi_bp = Blueprint('api', url_prefix='/api/v1')\n\n@api_bp.route('/users', methods=['GET'])\nasync def list_users():\n    users = get_all_users()  # Your data logic\n    return app.json_response({\n        \"users\": users,\n        \"count\": len(users)\n    })\n\n@api_bp.route('/users/{user_id}', methods=['GET', 'PUT', 'DELETE'])\nasync def handle_user(user_id):\n    if request.method == 'GET':\n        user = get_user_by_id(user_id)\n        if not user:\n            return app.json_response({\"error\": \"User not found\"}, status=404)\n        return app.json_response(user)\n    \n    elif request.method == 'PUT':\n        data = request.get_json()\n        updated_user = update_user(user_id, data)\n        return app.json_response(updated_user)\n    \n    elif request.method == 'DELETE':\n        delete_user(user_id)\n        return app.json_response({\"message\": \"User deleted\"})\n\napp.register_blueprint(api_bp)\n```\n\n---\n\n## 🛠️ Utilities \u0026 Helpers\n\n### CDN Resource Fetcher (PyDeJS)\n```python\ndeJS = PY_deJS()\n\n# Search for JavaScript libraries\njquery_results = deJS.get(search=\"jquery\", limit=1)\nminified_jquery = deJS.select(\"min\")\n\n# Use in templates\n@app.route(\"/\")\nasync def home():\n    return Templates(\"\"\"\n        \u003cscript src=\"{{ jquery_url }}\"\u003e\u003c/script\u003e\n        \u003ch1\u003ejQuery Loaded!\u003c/h1\u003e\n    \"\"\", jquery_url=minified_jquery)\n```\n\n---\n\n## 🚀 Deployment\n\n### Development Server\n```python\nif __name__ == '__main__':\n    app.run(host='0.0.0.0', port=8000, debug=True)\n```\n\n### Production Deployment\n\n#### Using Gunicorn\n```bash\npip install gunicorn\ngunicorn -w 4 -b 0.0.0.0:8000 app:app\n```\n\n#### Using Waitress\n```bash\npip install waitress\nwaitress-serve --host=0.0.0.0 --port=8000 app:app\n```\n\n### Nginx Configuration Example\n```nginx\nserver {\n    listen 80;\n    server_name yourdomain.com;\n    \n    location / {\n        proxy_pass http://127.0.0.1:8000;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n    }\n    \n    location /static/ {\n        alias /path/to/your/static/files/;\n        expires 30d;\n    }\n}\n```\n\n---\n\n## 📋 Best Practices\n\n### Project Structure\n```\nyour_project/\n│\n├── app.py                 # Application entry point\n├── config.py              # Configuration settings\n├── requirements.txt       # Dependencies\n│\n├── blueprints/            # Application modules\n│   ├── __init__.py\n│   ├── auth.py\n│   ├── api.py\n│   └── admin.py\n│\n├── static/                # Static assets\n│   ├── css/\n│   ├── js/\n│   └── images/\n│\n├── templates/             # Template files\n│   ├── base.shark\n│   ├── home.shark\n│   └── auth/\n│       ├── login.shark\n│       └── register.shark\n│\n├── utils/                 # Utility functions\n│   ├── __init__.py\n│   ├── auth.py\n│   └── helpers.py\n│\n└── tests/                 # Test files\n    ├── __init__.py\n    ├── test_auth.py\n    └── test_api.py\n```\n\n### Security Checklist\n- ✅ Use strong, unique `secret_key`\n- ✅ Store sensitive config in environment variables\n- ✅ Validate all user inputs\n- ✅ Use HTTPS in production\n- ✅ Implement proper error handling\n- ✅ Set appropriate file upload limits\n- ✅ Regular security updates\n\n### Performance Tips\n- Use async handlers for I/O-bound operations\n- Implement caching for frequently accessed data\n- Optimize database queries\n- Use CDN for static assets\n- Enable gzip compression\n- Monitor application performance\n\n---\n\n## 🤝 Contributing\n\nPieShark is designed to be lightweight yet powerful. Whether you're building a simple API, a complex web application, or a microservice, PieShark provides the tools you need without the bloat.\n\n### Why Choose PieShark?\n\n| Feature | PieShark | Other Frameworks |\n|---------|----------|------------------|\n| **Learning Curve** | Minimal | Steep |\n| **Built-in Security** | ✅ Encrypted sessions/cookies | ❌ Manual setup |\n| **Async Support** | ✅ Native | ⚠️ Plugin required |\n| **File Size** | Lightweight | Heavy |\n| **Flexibility** | High | Medium |\n\n---\n\n## 📚 Next Steps\n\n1. **Start Small** - Begin with a simple route and gradually add features\n2. **Explore Blueprints** - Organize your code into logical modules\n3. **Implement Security** - Leverage built-in encryption and session management\n4. **Scale Up** - Use async handlers and proper deployment strategies\n5. **Contribute** - Help make PieShark even better\n\n---\n\n*Ready to dive in? Start building your next web application with PieShark today! 🦈⚡*","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flcfhershell%2Fpiesharkx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flcfhershell%2Fpiesharkx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flcfhershell%2Fpiesharkx/lists"}