Skip to main content

High-performance Flask-like web framework with C++ backend

Project description

QSEWeb

High-performance web framework with C++ backend. Call Python from JavaScript easily.

Install

pip install qseweb

Example

import qseweb

app = qseweb.QSEWeb()

@app.assign("Btn")
def button():
    print("Button clicked")
    return "success"

@app.serve("/")
def main():
    return """
    <html>
    <body>
        <h1>Click the button</h1>
        <button onclick="button()">Click me</button>
        
        <script>
        async function button() {
            const response = await qse.Btn();
            alert(response);
        }
        </script>
    </body>
    </html>
    """

print("Starting server on http://localhost:5000")
app.run()

That's it! Run it and click the button.

How it works

  1. Use @app.assign("name") to expose Python functions
  2. Call them from JavaScript with await qse.name()
  3. Python function runs, returns result to JavaScript

API

Create app

app = qseweb.QSEWeb()              # Default: 0.0.0.0:5000
app = qseweb.QSEWeb(port=8080)     # Custom port

Make routes

@app.serve("/")
def home():
    return "<h1>Hello</h1>"

@app.serve("/about")
def about():
    return "<h1>About page</h1>"

Call Python from JavaScript

@app.assign("greet")
def greet(name):
    return f"Hello {name}!"
const msg = await qse.greet("World");  // "Hello World!"

Get request data

@app.serve("/api")
def api(request):
    user_id = request['query'].get('id')    # Query params
    method = request['method']              # GET, POST, etc
    path = request['path']                  # URL path
    body = request.get('body', '')          # Request body
    return f"User: {user_id}"

Stop server

app.stop()

# Or from web:
@app.serve("/shutdown")
def shutdown():
    import threading
    threading.Thread(target=app.stop, daemon=True).start()
    return "Stopping..."

Examples

python examples/basic.py              # Hello world
python examples/javascript_bridge.py  # JS ↔ Python
python examples/server_control.py     # Start/stop
python examples/advanced.py           # Full demo

Features

  • ✅ Flask-like API
  • ✅ Call Python from JavaScript (qse.function())
  • ✅ Multi-threaded C++ backend
  • ✅ Fast routing
  • ✅ Async with Ctrl+C support
  • ✅ Pre-compiled (no build needed)

Requirements

  • Python 3.7+
  • Windows (pre-compiled .pyd included)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qseweb-1.0.4.tar.gz (71.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qseweb-1.0.4-py3-none-any.whl (69.4 kB view details)

Uploaded Python 3

File details

Details for the file qseweb-1.0.4.tar.gz.

File metadata

  • Download URL: qseweb-1.0.4.tar.gz
  • Upload date:
  • Size: 71.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for qseweb-1.0.4.tar.gz
Algorithm Hash digest
SHA256 b82a0f95a0c85f1c20e56642fbfef1197ba4dcc55f9dca5380a1fa62f17cec19
MD5 dc2af250f57f470d1ce9ffb67829ab8d
BLAKE2b-256 5c7409ceaed51057d202d81c22336ff585eec4985a341ac082f7ae0197faabe1

See more details on using hashes here.

File details

Details for the file qseweb-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: qseweb-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 69.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for qseweb-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2d75e9dab9eb289cdf51528cfbd0f6d1394a100420418c4775d4cf6a5410cffd
MD5 f657d7a6fae1129ee730b519518f692d
BLAKE2b-256 853f72ce088fdcf56403eacdf528fe0431ced5c88a2be8bc05bb9638b570f5ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page