Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xweb

A web framework with very few code.

feature

  1. no dependencies
  2. very few code
  3. easy to use

install

pip install xweb

hello world

from xweb.application import XWeb

app = XWeb()


@app.route('/')
def hello():
    return 'hello world!'


app.listen(3000)

route

from xweb.application import XWeb

app = XWeb()


@app.route('/:name/')
def call_my_name(name):
    return 'hi {}!'.format(name)


app.listen(3000)

request

from xweb.globals import request

request.path
request.query_string
request.query
request.files
request.forms
request.json
request.ip
request.hostname
request.headers

response

from xweb.globals import response

response.headers
response.status
response.body

middleware

from xweb.application import XWeb

app = XWeb()

@app.middleware('request')
def print_on_request1():
    print("I print when a request is received by the server1")


@app.middleware('request')
def print_on_request2():
    print("I print when a request is received by the server2")


@app.middleware('response')
def print_on_response1():
    print("I print when a response is returned by the server1")


@app.middleware('response')
def print_on_response2():
    print("I print when a response is returned by the server2")

@app.route('/:name/')
def call_my_name(name):
    return 'hi {}!'.format(name)


app.listen(3000)

test

  1. pip install -r requirement.txt

  2. pytest

contribution

  1. star
  2. fork
  3. add your code
  4. add test code and run test
  5. pull request

TODO

important:

  1. auto-reload
  2. more test code
  3. rewrite global request and response

normal:

  1. more http status code
  2. some necessary middleware
  3. support blueprint
  4. a cool logo

About

A web framework with very few code.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages