#!/usr/bin/env python
#
# user_info.py
# Author: Zex <top_zlynch@yahoo.com>

def create_html(xlsname, sheetname):
    data = {}
    data['userid'] = [23,4,36,14,1,63,123]
    data['useremail'] = [
        'x3sd@sfsf.com',
        'x5sd@sfsf.com',
        'x2sd@sfsf.com',
        'x4sd@sfsf.com',
        'xasd@sfsf.com',
        'x35sd@sfsf.com',
        'x234sd@sfsf.com',
    ]
    print "<label>helo</label>"
    from pandas import DataFrame
    print "<label>helo</label>"
    xls = DataFrame(data)
    #xls.to_excel(xlsname, sheetname, index=False)
    return xls.to_html(index=False)

def reply():
    import cgi
#    fields = cgi.FieldStorage()
    title = "User Info"
    
    print "Content-Type: text/html\n\n"
    print "<!DOCTYPE html>"
    print "<html>"
    
    print "<head>"
    print "<title>", title, "</title>"
    print "<link href=\"/css/basic.css\" rel=\"stylesheet\" type=\"text/css\">"
    print "<meta charset=\"UTF-8\">"
    print "</head>"
    
    print "<body>"
    
    print create_html('all-log-pandas.xls', 'user-info')
    
    print "</body>"
    print "</html>"

#if __name__ == '__main__':
reply()


@@ -70,16 +70,36 @@
 o.com%3E%0A%0A
+from navi import *%0A%0A
 def crea
@@ -127,16 +127,17 @@
 tname):%0A
+%0A
     data
@@ -399,39 +399,8 @@
   %5D%0A
-    print %22%3Clabel%3Ehelo%3C/label%3E%22
 %0A   
@@ -433,40 +433,8 @@
 ame%0A
-    print %22%3Clabel%3Ehelo%3C/label%3E%22%0A
     
@@ -560,55 +560,8 @@
 ():%0A
-    import cgi%0A#    fields = cgi.FieldStorage()
 %0A   
@@ -585,26 +585,40 @@
 fo%22%0A    
-%0A    print
+ret = %22%22%0A    %0A    ret +=
  %22Conten
@@ -644,21 +644,22 @@
 %5Cn%22%0A    
-print
+ret +=
  %22%3C!DOCT
@@ -669,29 +669,30 @@
  html%3E%22%0A    
-print
+ret +=
  %22%3Chtml%3E%22%0A  
@@ -702,213 +702,79 @@
     
-print %22%3Chead%3E%22%0A    print %22%3Ctitle%3E%22, title, %22%3C/title%3E%22%0A    print %22%3Clink href=%5C%22/css/basic.css%5C%22 rel=%5C%22stylesheet%5C%22 type=%5C%22text/css%5C%22%3E%22%0A    print %22%3Cmeta charset=%5C%22UTF-8%5C%22%3E%22%0A    print %22%3C/head%3E%22%0A    %0A    print
+ret += default_head(title) %0A    ret += default_navigator() %0A%0A    ret +=
  %22%3Cb
@@ -788,21 +788,22 @@
    %0A    
-print
+ret +=
  create_
@@ -847,29 +847,30 @@
 ')%0A    %0A    
-print
+ret +=
  %22%3C/body%3E%22%0A 
@@ -876,13 +876,14 @@
     
-print
+ret +=
  %22%3C/
@@ -890,16 +890,31 @@
 html%3E%22%0A%0A
+    print ret%0A%0A
 #if __na
@@ -937,13 +937,115 @@
 _':%0A
-reply()%0A
+%0Afrom os import environ%0A%0Aenviron%5B'MPLCONFIGDIR'%5D = %22/tmp%22%0A%0Atry:%0A    reply()%0Aexcept Exception as e:%0A    print e
 %0A

add environ for matlab