Comments (2)
I will start working on this
from dominate.
Here is my proposed format for server configs:
'''
format of httpserver.sites:
[ SPECIFIER, HANDLER, ... ]
where SPECIFIER is one of:
* a regular expression string - matches that hostname (or uri, in a sub-handler)
* an HTTP error code - matches that error code
* HTTPError - matches all errors
* None - matches None or the empty string
* True - matches everything
If no specifiers match, an HTTPError(404) will be raised.
If multiple SPECIFIERs match, the last one will be used. If the last one raises a 404 error, then the second last one will be used, etc.
Note that if a leaf-node (final handler) raises a 404, that error will be handled normally and will not cause the resolver to keep looking
and HANDLER is one of:
* [ SPECIFIER, HANDLER, ...] - to do further processing
* a function object - will be called with f(*args) where args is a list of all regex matches that were encountered in the entire processing of this request. The function's return value will then be used as a new HANDLER
* a handler object - will be called with .handle(httpserver, request, response, *args) (or .handle_error(..) if this is an error match)
* None - do nothing
* an HTTPError instance - this error will be raised
'''
# an example:
sites = [
True, [
# example.zkpq.ca didn't match, redirect the user to the right hostname
'^/.*$', HTTPError(302, 'http://example.zkpq.ca')
]
'^example.zkpq.ca$', [
'^/(\w+)$', lambda x:pyyscript ('.', '%s.py' %x), # need lambda to add '.py'
'^/src(.*)$', lambda x:syntaxfileserver ('../..', x), # serve the source dir with highlighting. don't need a lambda here, but it works
'^/doc(.*)$', fileserver('../', x), # serve the documentation
HTTPError: lambda :pyyscript('.', 'error.py'), # generic error
404: lambda :pyyscript('.', '404.py'), # specific error
]
]
# TODO: make pyy_httpserver acctually implement this!
from dominate.
Related Issues (20)
- Question: how to render a boolean attribute? HOT 1
- Integration with Flask (or other framework) ? HOT 1
- maximum recursion depth exceeded in comparison HOT 2
- Allow to specify document language HOT 2
- Underscore character "_" to create colon character ":" in HTML HOT 1
- request parameter is unused and undocumented? HOT 1
- Some HTML5 tags are missing
- Custom elements HOT 1
- Prevent escaping of attributes?
- Repeatedly calling attr() on same attribute doesn't accumulate values HOT 1
- tag(attr=None) renders as <tag attr="None"></tag>
- pip usage HOT 1
- support recursive with dominate.document() HOT 4
- Release Notes HOT 1
- Enable attributes without values HOT 2
- Treat None as an empty string?
- Add hyper link within a string of text
- Replace deprecated imp module with importlib HOT 2
- unexpected context behaviour HOT 4
- tests/test_dom_tag.py:20: AssertionError while building for i686 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dominate.