File: index.py

package info (click to toggle)
weborf 0.13-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 916 kB
  • ctags: 429
  • sloc: ansic: 3,069; sh: 1,165; python: 535; makefile: 76
file content (31 lines) | stat: -rw-r--r-- 665 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
This is an example of index file.
It adds a "." to a session variable on every refresh, shows the informations and sets a cookie.
'''

import os
import sys
from cgi_weborf import * #imports module cgi

cgi.session_start() 
cgi.setcookie("id","33")

cgi.finalize_headers() #will output the final \r\n\r\n and the content-type header

if 'nome' in cgi.SESSION:
        cgi.SESSION['nome']+="."
else:
        cgi.SESSION['nome']="."

sys.stdout.write( "<html>")
sys.stdout.write( "<body>")

sys.stdout.write( "<h1>example</h1>")
cgi.pyinfo()
sys.stdout.write(  "</body>")
sys.stdout.write(  "</html>")

cgi.savesession()