# Path: duckpond/apps/editor/app.py
# def before_request():
# 
# Path: duckpond/apps/editor/forms.py
# class LoginForm(FlaskForm):
#     username = StringField('username', validators=[DataRequired()])
#     password = StringField('password', validators=[DataRequired()])
#     redirectonlogin = StringField('redirectonlogin', default='true',validators=[])


from flask import render_template, redirect, session, request, url_for, escape, flash, g, make_response, stream_with_context, Response
from functools import wraps
from .app import app
from .forms import LoginForm
from . import model
import json
import requests
            session['username'] = username
            print("rediect="+form.redirectonlogin.data)
            if form.redirectonlogin.data=='true':
               return redirect('/')
            else:
               return render_template('login-successful.html',
                                      title='Duckpond Content Editor',
                                      username=session['username'])
         else:
            flash('Login for {} failed.'.format(username))
            failed = True
      except AttributeError:
         flash('Login for {} failed.'.format(username))
         failed = True

   compact = request.args.get('compact')
   requestRedirect = request.args.get('redirect')
   form.redirectonlogin.data = requestRedirect if requestRedirect is not None else 'true'

   return render_template('login.html' if compact is None or compact=='false' else 'login-compact.html',
                           title='Sign In',
                           failed=failed,
                           form=form)

@app.route('/logout')
def logout():
    # remove the username from the session if it's there
    session.clear()
    return redirect(url_for('index'))


# Path: duckpond/apps/editor/app.py
# def before_request():
# 
# Path: duckpond/apps/editor/forms.py
# class LoginForm(FlaskForm):
#     username = StringField('username', validators=[DataRequired()])
#     password = StringField('password', validators=[DataRequired()])
#     redirectonlogin = StringField('redirectonlogin', default='true',validators=[])


# Path: duckpond/apps/editor/views.py
from flask import render_template, redirect, session, request, url_for, escape, flash, g, make_response, stream_with_context, Response
from functools import wraps
from .app import app
from .forms import LoginForm
from . import model
import json
import requests

            session['username'] = username
            print("rediect="+form.redirectonlogin.data)
            if form.redirectonlogin.data=='true':
               return redirect('/')
            else:
               return render_template('login-successful.html',
                                      title='Duckpond Content Editor',
                                      username=session['username'])
         else:
            flash('Login for {} failed.'.format(username))
            failed = True
      except AttributeError:
         flash('Login for {} failed.'.format(username))
         failed = True

   compact = request.args.get('compact')
   requestRedirect = request.args.get('redirect')
   form.redirectonlogin.data = requestRedirect if requestRedirect is not None else 'true'

   return render_template('login.html' if compact is None or compact=='false' else 'login-compact.html',
                           title='Sign In',
                           failed=failed,
                           form=form)

@app.route('/logout')
def logout():
    # remove the username from the session if it's there
    session.clear()
    return redirect(url_for('index'))


@app.route('/proxy/<name>/<path:path>')