Skip to main content

A fast and minimalistic Python web framework with no external dependencies

Project description

README.md

WebInter

WebInter is a minimalist Python web framework that allows you to quickly create websites and APIs without external dependencies. It provides everything you need for building simple web applications, from routing to serving static files and templates, all in a lightweight package.

Features

  • No external dependencies – Everything is implemented in WebInter, so you don't need to install any third-party libraries.
  • Support for static files – Serve CSS, JavaScript, and image files directly from your project.
  • HTML Templates – Easily handle dynamic HTML content with simple string-based templates.
  • JSON-based APIs – Create and manage RESTful APIs with minimal effort.
  • Request and Response Handling – Simple and efficient ways to handle HTTP requests and responses.
  • Easy to Use – Get your web applications up and running in no time.

Installation

Install WebInter easily using pip:

pip install webinter

Once installed, you can start building your web applications without worrying about additional dependencies.

Example Usage

Here’s a simple example that demonstrates how to create a basic web server using WebInter.

Basic Web Server Example

from webinter import WebInter

# Initialize the WebInter app with host and port
app = WebInter(host="127.0.0.1", port=8080)

# HTML Template Route - Render a simple message
@app.route("/", "<h1>This page runs with WebInter!</h1><p>Welcome to WebInter, the minimalist Python web framework.</p>")

# Static File Route - Serve static files (e.g., CSS)
app.add_static_file("style.css", "body { background-color: lightblue; font-family: Arial, sans-serif; }")
@app.route("/static/style.css", static=True)

# Start the web server
if __name__ == "__main__":
    app.run()

Explanation:

  • @app.route(): This is how you define a route. The first argument is the URL path, and the second argument is either a string (for static HTML) or a function (for dynamic content).

  • Static File Handling: The method add_static_file() is used to define a static file (like a CSS file) that will be served to users when they access the corresponding route.

Running the Application

After running the script, navigate to http://127.0.0.1:8080/ in your browser to see the page displaying:

This page runs with WebInter!
Welcome to WebInter, the minimalist Python web framework.

Static Files

WebInter makes it easy to serve static assets like CSS, JavaScript, and images. Just place the file in your project and use the add_static_file() method.

For example, you can serve a CSS file like this:

app.add_static_file("style.css", "body { background-color: lightblue; }")
@app.route("/static/style.css", static=True)

You can then link to it in your HTML templates:

<link rel="stylesheet" href="/static/style.css">

Project Structure

Here’s how your project should be structured:

/webinter_project
    /webinter
        __init__.py
    /static
        style.css
    setup.py
    README.md

Conclusion

With WebInter, you can easily create web applications with minimal setup. Whether you're building a simple website, API, or more complex application, WebInter provides an easy-to-use framework that’s perfect for quick projects and learning.

For more information, feel free to check the examples in the repository and explore how you can extend WebInter to suit your needs!

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

webinter-0.4.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

WebInter-0.4-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file webinter-0.4.tar.gz.

File metadata

  • Download URL: webinter-0.4.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for webinter-0.4.tar.gz
Algorithm Hash digest
SHA256 3b4db027bc9c6c16418f5dc4c1a01808b2668339a39c8aef6a7a7971d925cc39
MD5 64dba397dd6621830d387a7d975a9773
BLAKE2b-256 4fda8eee5d415f5511c631c2cb9cafcfc72dcbcf2db4814b7c80292c4b211bd3

See more details on using hashes here.

File details

Details for the file WebInter-0.4-py3-none-any.whl.

File metadata

  • Download URL: WebInter-0.4-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for WebInter-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e7b1f546af664db1373e87b2b9a032be22802d5d4c93a8128299a85926c7fc43
MD5 88c447dfac2c06062ac774084781517c
BLAKE2b-256 f40cfa5b8fd99dbba1014cef91f38054c7375d9ba733f4af4f96f0ced9d693fa

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