installing
pip install p4rr0t007
5-minute example
create yourapp folder
mkdir -p yourapp/{templates,static}
touch yourapp/__init__.py
touch yourapp/application.py
create an index.html template
mkdir -p yourapp/{templates,static}
cat > yourapp/templates/index.html << EOF
<html>
<head>
<title>hello world</title>
</head>
<body>
<h1>hello world</h1>
<pre>{{ now }}</pre>
<br />
<hr />
<br />
<a href="{{ url_for('html') }}">html</a>
<a href="{{ url_for('text') }}">text</a>
<a href="{{ url_for('json') }}">json</a>
</body>
</html>
EOF
create an index.html template
cat > yourapp/application.py << EOF
import os
from plant import Node
from datetime import datetime
from p4rr0t007.web import Application
node = Node(__file__)
server = Application(node)
@server.route('/')
def html():
return app.template_response('index.html', {'now': datetime.utcnow().isoformat()})
@server.route('/text')
def text():
return app.text_response('text')
@server.route('/json')
def json():
return app.json_response({
'name': 'p4rr0t007'
}, code=200)
if __name__ == '__main__':
settings.update(
SECRET_KEY=os.urandom(32).encode('base64').strip(),
)
server.run(debug=True)
EOF
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
p4rr0t007-0.1.4.tar.gz
(1.1 MB
view details)
File details
Details for the file p4rr0t007-0.1.4.tar.gz.
File metadata
- Download URL: p4rr0t007-0.1.4.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c5b0cffcb1fc4fb9ff7cdcf1d8086af357ce606dcf281bbaea7322ab69e2870
|
|
| MD5 |
af0a764c7c9d11d44b874421df8055dc
|
|
| BLAKE2b-256 |
cd99c54f8d3cf0c0657a1bb6902b9288e832a0067f6955561d3d2c4a017cd4a0
|