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
    
    /static
        style.css
    
    main.py

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: webinter-0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 c29ff95f029b7ba46ca733177ef60e38d7cf4e60e09a5150366075dbe56ea16b
MD5 77bffef2fe3302e9ad2bdb417069378e
BLAKE2b-256 c3264a9294b543576e3f80d7b733ef36e41eb22eb2048db8ba69536eef343a7a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: WebInter-0.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d50f94cf5be4b5d641043bb7de9dd8d89498ea7a118e3944c4eea2e04f6decfc
MD5 7bd7414cdfeaf25eb01f99a91c40e58a
BLAKE2b-256 8402aaf2825610d07944bafd452cf27b4a4ee6cf2fc5ffb3eb61c0b7df37c19d

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