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`:

```bash
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.3.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.3-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: webinter-0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 1065a3a2c5fc6a55ffda07a019f480e395c81a43f939888aca5fd33054407653
MD5 c664fd05f78319a522b510c648add914
BLAKE2b-256 1dc8ebe58b56ea379a5edfb6050b434db2dcc5546484630777adb23a4941a943

See more details on using hashes here.

File details

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

File metadata

  • Download URL: WebInter-0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d3cb5267f995b3708a404505cc6cf9cf5d05f1c8974e4cd87eeb5f4364a5f875
MD5 db5794fee269ea18765a14e4fc551090
BLAKE2b-256 900dfd5afa73e948391e321643c671adebce0c0f3c79a57448da52dfd00fe6e9

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