def getWish(): _user = session.get('user') wishes = [] wishlist={} cur,conn = connection() cur.execute('select * from wishlist where uid = %s',(_user, )) wish = cur.fetchall() for w in wish: wishes.append(w[1]) items = Content() for item in items: for itm in items[item]: for w in wishes: if w == itm: wishlist[w]=items[item][w] home_items = homeContent() for item in home_items: for itm in home_items[item]: for w in wishes: if w == itm: wishlist[w] = home_items[item][w] return wishlist
def _url_update(categoryList, productname, filename): dict1 = Content() dict2 = Database() categoryList = list(categoryList) a = [] for i in range(len(categoryList)): a.append(CAT_DICT[categoryList[i]]) dict1[productname] = []
def mens_clothing(): items=Content() if request.method == "POST": if 'logged_in' in session: addWish(items) else: flash("You need to login first") return render_template('mensclothing.html', items=items)
def mobile_phones(): items=Content() if request.method == "POST": if 'logged_in' in session: addWish(items) else: flash("You need to login first") return render_template('mobilephones.html', items=items)
from flask import Flask, render_template, request , url_for, redirect from content_management import Content from flaskext.mysql import MySQL Topic_dict=Content() import MySQLdb mysql = MySQL() app = Flask(__name__) app.config['MYSQL_DATABASE_USER'] = '******' app.config['MYSQL_DATABASE_PASSWORD'] = '******' app.config['MYSQL_DATABASE_DB'] = 'login' app.config['MYSQL_DATABASE_HOST'] = 'localhost' mysql.init_app(app) @app.route('/') def home(): return render_template("main.html") @app.route('/dashboard/<int:username>') def dashboard(username): return render_template("dashboard.html",Topic_dict=Topic_dict) @app.errorhandler(404) def page_not_found(e): return ("try again") def connection(): db = MySQLdb.connect(host="localhost", user="******", passwd="himanshi", db="login") c=db.cursor() #c.execute("SELECT * FROM login_data where Username='******' and Password='******'") # c.commit()
__author__ = 'Filip Wachowiak' import gc from models import Like from functools import wraps from flask import Flask, render_template, flash, request, redirect, url_for, session, send_file from content_management import Content, python_content, gpu_content, kotlin_content from pymysql import escape_string as thwart from passlib.hash import sha256_crypt from wtforms import Form, validators, StringField, PasswordField, BooleanField from dbconnect import connection from flask_mail import Mail, Message from __init__ import app from __init__ import db GROUP_LIST = Content() PYTHON_ARTICLES = python_content() GPU_ARTICLES = gpu_content() KOTLIN_ARTICLES = kotlin_content() like = Like() def likes_setter(article, username): if not Like.query.filter_by(username=username, post=article[0]).first(): like.post = article[0] like.username = username db.session.add(like) db.session.commit()
# A very simple Flask Hello World app for you to get started with... import os from flask import Flask, render_template, Markup from content_management import Content import numpy as np app = Flask(__name__) listcontent = Content() @app.route('/') def homepage(): return render_template("index.html") @app.route('/projects/') def projects(): return render_template("projects.html", projects=listcontent.projects_list) @app.route('/blog/') @app.route('/blog/categories/<category>') def blog_content(content=None, category='None'): return render_template("content.html", menu=listcontent.content_dict, top5=listcontent.top5(), content=content,
from flask import Flask, render_template, flash, request, url_for, redirect, session from content_management import Content from wtforms import Form, BooleanField, TextField, PasswordField, validators from passlib.hash import sha256_crypt from MySQLdb import escape_string as thwart from functools import wraps from dbconnect import connection import gc TOPIC = Content() app = Flask(__name__) class RegistrationForm(Form): username = TextField('Username', [validators.Length(min=4, max=20)]) email = TextField('Email Address', [validators.Length(min=6, max=50)]) password = PasswordField('Password', [validators.Required(), validators.EqualTo('confirm', message="Passwords must match.")]) confirm = PasswordField('Repeat Password') accept_tos = BooleanField('I accept the <a href="/tos/">Terms of Service</a> and the <a href="/privacy/">Privacy Notice</a> (Last updated never)', [validators.Required()]) @app.route('/', methods=["GET", "POST"]) def homepage(): return render_template("index.html") @app.route('/dashboard')
from content_management import Content import os topics_dict = Content() html_template = ''' {% extends 'header.html' %} {% block body %} <body class="body"> <div class="container" align="left" style="max-width:800px"> <h2>{{curTitle}}</h2> <br> <div class="embed-responsive embed-responsive-16by9"></div> <p></p> <p></p> <p></p> <p></p> <kbd data-toggle="collapse" data-target="#consoleinfo" aria-expanded="false" aria-controls="consoleinfo">console</kbd> <div class="collapse" id="consoleinfo"> <div class="well"> <p>When someone refers to "the console," they are referring to where information from your program is ouput. You will see an example of "output to console" below. If you want this message to go away, just click again on the "console" button that you originally clicked on.</p> </div> </div> <div class="row"> <div class="col l6"> <pre class="prettyprint"> CODE HERE
def dashboard(): return render_template("dashboard.html", TOPIC_DICT = Content() )
''' @app.route('/Java/') def java(): try: return render_template("Java.html", page_dict=page_dict) except Exception as e: return(str(e)) ''' # This will import a dictionary I previously defined. The diction has three separate values associated with it; # location, language, and tutorial # This file will pull the dictionary information, and create all of the app.route we will require for Meraki from content_management import Content # declare a dictionary variable from the content_management py file page_dict = Content() # function with arguments (language, tutorial) def create_list(l, t): language = l tab = " " print(tab) print("@app.route('/" + language + "/" + t + "/')") print("@login_required") print("def " + language.lower() + "_" + t + "():") print(tab + "un = get_un()") print(tab + "try:") print(tab + tab + "return render_template(\"languages/" + language + "/" + t + ".html\", page_dict=page_dict, un=un)") print(tab)
import forms from flask import Flask,render_template,url_for,request,redirect,flash import datetime import read_database app = Flask(__name__) from content_management import Content,Database, Write_Cont, Write_DB from services_content_management import services_content, mall_content from flask.ext.login import * CONT_DICT = Content() SERV_DICT = services_content() MALL_DICT = mall_content() app.secret_key = 'sdkjfjkja' DATABASE_DICT = Database() @app.route('/') def index(): return render_template('index.html') @app.route('/about') def about(): return render_template('about.html') global product @app.route('/product') def product(): """ Controls the coming of the graph on the first search and of course the subsequent ones. The product being searched comes via here """ product=request.args['product']
from flask import Flask, render_template, flash, request, url_for, redirect #url_for allows us to get the url for a function from content_management import Content #import Content() class from dbconnect import connection TOPIC_DICT = Content( ) #create variable and set it as the Content() class with the returned list app = Flask(__name__) @app.route('/') def homepage(): return render_template("main.html") # @app.route('/slashboard/') #whatever function is provided below the route will appear, hence both /slashboard and #/dashboard will render the 'hi' page @app.route('/dashboard/') def dashboard(): # return render_template("main.html") # flash("flash test!!!") return render_template( "dashboard.html", TOPIC_DICT=TOPIC_DICT ) #the first TOPIC_DICT is what will be referenced in the HTML @app.errorhandler( 404 ) #app is the above app = Flask(__name__) and errorhandler is part of Flask
from flask import Flask, render_template, flash, request, url_for, redirect, session from content_management import Content from dbconnect import connection from flask_wtf import FlaskForm from wtforms import Form, TextField, PasswordField, BooleanField from wtforms.validators import DataRequired, EqualTo, Length from passlib.hash import sha256_crypt from MySQLdb import escape_string as thwart import gc from functools import wraps TOPIC_DIST = Content() app = Flask(__name__) app.secret_key = 'some_secret' @app.route("/") def homepage(): return render_template('/main.html') @app.route("/dashboard/") def dashboard(): flash("flash message!!") return render_template('/dashboard.html', TOPIC_DIST=TOPIC_DIST) @app.errorhandler(404) def page_not_found(e): return render_template('404.html')
from flask import Flask, render_template, flash, url_for, redirect, request, session, make_response, send_file, send_from_directory from wtforms import Form, BooleanField, TextField, PasswordField, validators from datetime import datetime, timedelta from passlib.hash import sha256_crypt from MySQLdb import escape_string as thwart import gc import os from functools import wraps from content_management import Content from db_connect import connection from search import search APP_CONTENT = Content() UPLOAD_FOLDER = "/var/www/FlaskApp/FlaskApp/uploads" ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif']) app = Flask(__name__, instance_path='/var/www/FlaskApp/FlaskApp/uploads') app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER def login_required(f): @wraps(f) def wrap(*args, **kwargs): if 'logged_in' in session: return f(*args, **kwargs) else: flash("Please login.") return redirect(url_for('login_page')) return wrap
import os from flask import Flask, render_template, flash, request, redirect, url_for, session from content_management import Content from wtforms import Form, BooleanField, TextField, PasswordField, validators from dbconnect import connection from passlib.hash import sha256_crypt from MySQLdb import escape_string as thwart from functools import wraps import gc from flask_socketio import SocketIO, send app = Flask(__name__) DIC = Content() app.config['SECRET_KEY'] = '51m1pr4mb05' socketio = SocketIO(app) #ext func ######################################################################################################################### class RegistrationForm(Form): username = TextField('Username', [validators.Length(min=4, max=20)]) email = TextField('Email Address', [validators.Length(min=6, max=50)]) password = PasswordField('Password', [ validators.Required(), validators.EqualTo('confirm', message='Passwords must match') ]) confirm = PasswordField('Confirm Password') accept_tos = BooleanField( 'I accept the Terms of Service and Privacy Notice', [validators.Required()])
sys.path.append("/var/www/FlaskApp/FlaskApp") import os from flask import Flask, render_template, flash, request, url_for, redirect, session from content_management import Content from wtforms import Form, BooleanField, TextField, PasswordField, validators from passlib.hash import sha256_crypt from MySQLdb import escape_string as thwart from functools import wraps from dbconnect import connection import gc TOPIC_DICT = Content() app = Flask(__name__) app.secret_key = os.urandom(12) @app.route('/') def homepage(): return render_template("header.html") #@app.route('/slashboard/') @app.route('/dashboard/') def dashboard(): #return ("hi") #flash("flash test!!!") print(session) return render_template("dashboard.html", TOPIC_DICT = TOPIC_DICT)
from flask import Flask, render_template, request, flash, redirect, url_for, session from passlib.hash import sha256_crypt from MySQLdb import escape_string as thwart import gc, requests from scripts import dbconnect from content_management import Content BOOK_DETAILS = Content() app = Flask(__name__) @app.route('/') def index(): return render_template("main.html") @app.route('/login/') def login_page(): return render_template("login.html") #@app.route('dash-board/') @app.route('/dashboard/') def dashboard(): #add login functionality to database if (True): return render_template("dashboard.html", Book_details=BOOK_DETAILS) #else: #promt error on login form