<s> from os import path <EOL> from json import dumps <EOL> from flask import Flask , redirect , request <EOL> from flask . ext . autodoc import Autodoc <EOL> app = Flask ( __name__ ) <EOL> app . debug = True <EOL> auto = Autodoc ( app ) <EOL> users = [ ] <EOL> posts = [ ] <EOL> class User ( object ) : <EOL> def __init__ ( self , username ) : <EOL> self . username = username <EOL> users . append ( self ) <EOL> self . id = users . index ( self ) <EOL> def __repr__ ( self ) : <EOL> return dumps ( self . __dict__ ) <EOL> class Post ( object ) : <EOL> def __init__ ( self , title , content , author ) : <EOL> self . title = title <EOL> self . content = content <EOL> posts . append ( self ) <EOL> self . id = posts . index ( self ) <EOL> def __repr__ ( self ) : <EOL> return dumps ( self . __dict__ ) <EOL> u = User ( '<STR_LIT>' ) <EOL> Post ( '<STR_LIT>' , '<STR_LIT>' , u ) <EOL> Post ( '<STR_LIT>' , '<STR_LIT>' , u ) <EOL> @ app . route ( '<STR_LIT:/>' ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> @ auto . doc ( groups = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def get_posts ( ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT:%s>' % posts <EOL> @ app . route ( '<STR_LIT>' ) <EOL> @ auto . doc ( groups = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def get_post ( id ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT:%s>' % posts [ id ] <EOL> @ app . route ( '<STR_LIT>' , methods = [ "<STR_LIT:POST>" ] ) <EOL> @ auto . doc ( groups = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> form_data = [ '<STR_LIT:title>' , '<STR_LIT:content>' , '<STR_LIT>' ] ) <EOL> def post_post ( ) : <EOL> """<STR_LIT>""" <EOL> authorid = request . form . get ( '<STR_LIT>' , None ) <EOL> Post ( request . form [ '<STR_LIT:title>' ] , <EOL> request . form [ '<STR_LIT:content>' ] , <EOL> users [ authorid ] ) <EOL> return redirect ( "<STR_LIT>" ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> @ auto . doc ( groups = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def get_users ( ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT:%s>' % users <EOL> @ app . route ( '<STR_LIT>' ) <EOL> @ auto . doc ( groups = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def get_user ( id ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT:%s>' % users [ id ] <EOL> @ app . route ( '<STR_LIT>' , methods = [ '<STR_LIT:POST>' ] ) <EOL> @ auto . doc ( groups = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> form_data = [ '<STR_LIT:username>' ] ) <EOL> def post_user ( id ) : <EOL> """<STR_LIT>""" <EOL> User ( request . form [ '<STR_LIT:username>' ] ) <EOL> redirect ( '<STR_LIT>' ) <EOL> @ app . route ( '<STR_LIT>' , methods = [ '<STR_LIT:GET>' ] ) <EOL> @ auto . doc ( groups = [ '<STR_LIT>' ] ) <EOL> def admin ( ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' <EOL> @ app . route ( '<STR_LIT>' ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def public_doc ( ) : <EOL> return auto . html ( groups = [ '<STR_LIT>' ] , title = '<STR_LIT>' , template = "<STR_LIT>" ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def private_doc ( ) : <EOL> return auto . html ( groups = [ '<STR_LIT>' ] , title = '<STR_LIT>' , template = "<STR_LIT>" ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app . run ( ) </s>
