예제 #1
0
def list_apps():
    apps = AdNetwork.all()
    form = AppForm()
    if form.validate_on_submit():
         file = request.files['app_url'] 
         if file:
            filedata = file.read()
            ext = file.filename.rsplit('.', 1)[1]
            content_type = file.content_type
            app_filename = file.filename
            applist = AdNetwork(
                app_title = request.form['app_title'],
                app_category = request.form['app_category'],
                app_name = app_filename,
                app_url = db.Blob(filedata),
                ext = ext,
                content_type = content_type,
                app_link = request.form['app_link'],
                new = form.new.data,
                exclusive =  form.exclusive.data
            )
            try:
                applist.put()
                app_id = applist.key().id()
                flash(u'App Profile is %s successfully saved.' % app_id, 'success')
                return redirect(url_for('apps'))
            except CapabilityDisabledError:
                flash(u'App Engine Datastore is currently in read-only mode.', 'info')
                return redirect(url_for('apps'))
         return render_template('list_apps.html', apps=apps, form=form)              
    return render_template('list_apps.html', apps=apps, form=form)
예제 #2
0
def delete_app(app_id):
    """Delete an example object"""
    app = AdNetwork.get_by_id(app_id)
    try:
        app.delete()
        flash(u'App %s successfully deleted.' % app_id, 'success')
        return redirect(url_for('apps'))
    except CapabilityDisabledError:
        flash(u'App Engine Datastore is currently in read-only mode.', 'info')
        return redirect(url_for('apps'))
예제 #3
0
def get_img(app_id):
        """k = db.Key.from_path('MediaKit', category_id)""" 
        applist = AdNetwork.get_by_id(app_id)
        return app.response_class(applist.app_url,mimetype=applist.content_type,direct_passthrough=False)