from flask import Flask, render_template, redirect, flash, url_for, session, request, logging from data import Articles import sqlite3 as MySQL from flaskext.mysql import MySQL #from flask_mysql import MySQL from wtforms import Form, StringField, TextAreaField, PasswordField, validators from passlib.hash import sha256_crypt #if __name__ == '__main__': # main() app = Flask(__name__) Articles = Articles() @app.route('/') def index(): return render_template('home.html') @app.route('/home') def home(): return render_template('home.html') @app.route('/about') def about(): return render_template('about.html') @app.route('/donarreg') def donarreg(): return render_template('donarreg.html') @app.route('/ngo')
from flask import Flask, render_template from data import Articles app = Flask(__name__) articles_data = Articles() @app.route('/') def index(): return render_template('home.html') @app.route('/news') def news(): return render_template('news.html') @app.route('/articles') def articles(): return render_template('articles.html', articles=articles_data) @app.route('/article/<string:id>') def article(id): return render_template('article.html', id=id) @app.route('/about') def about(): return render_template('about.html')
from flask import Flask, render_template, session, request, flash, logging, url_for, redirect from flask_mysqldb import MySQL from wtforms import Form, StringField, PasswordField, TextAreaField, validators from passlib.hash import sha256_crypt from functools import wraps from data import Articles app = Flask(__name__) articles1 = Articles() # Here we will configure app to use mysql database for storage of data and user credentials app.config['MYSQL_HOST'] = 'localhost' app.config['MYSQL_USER'] = '******' app.config['MYSQL_PASSWORD'] = '******' app.config['MYSQL_CURSORCLASS'] = 'DictCursor' app.config['MYSQL_DB'] = 'myflaskapp' #iniializing the database now mysql = MySQL(app) @app.route('/') def home(): return render_template('home.html') @app.route('/about') def about(): return render_template('about.html')
# Config MySQL app.config['MYSQL_HOST'] = '' app.config['MYSQL_USER'] = '' app.config['MYSQL_PASSWORD'] = '' app.config['MYSQL_DB'] = 'flask_blog_app' # By default the db cursor returns touples as a result of query # to get dictionary object set DictCursor as cursor class app.config['MYSQL_CURSORCLASS'] = 'DictCursor' # init MySQL mysql = MySQL(app) # Get articles. As there is no db setup for articles just get # the articles from a static python file all_articles = Articles() # Index page of application @app.route('/') def hello_world(): return render_template('home.html') @app.route('/about') def about(): return render_template('about.html') @app.route('/articles') def articles():
def article(id): return render_template('article.html', article=Articles()[id])
def articals(): return render_template('articles.html', articles=Articles())
# config MySQL app.config['MYSQL_HOST'] = 'localhost' app.config['MYSQL_USER'] = '******' app.config['MYSQL_APSSWORD'] = '' app.config['MYSQL_DB'] = 'myflaskapp' app.config['MYSQL_CURSORCLASS'] = 'DictCursor' # config SECRET_KEY app.config['SESSION_TYPE'] = 'memcached' app.config['SECRET_KEY'] = 'super secret key' # init MySQL mysql = MySQL(app) Article = Articles() @app.route('/') def index(): return render_template('home.html') @app.route('/about') def about(): return render_template('about.html') @app.route('/articles') def articles(): return render_template('articles.html', articles=Articles)
def article(id): print(id) articles = Articles()[id - 1] print(articles) return render_template('article.html', data=articles)
def articles(): print("Success") # return "TEST" articles = Articles() print(len(articles)) return render_template('articles.html', articles=articles)
from flask import Flask, render_template, flash, redirect, url_for, logging, session, request from wtforms import Form, StringField, TextAreaField, PasswordField, validators from passlib.hash import sha256_crypt from data import Articles from classes import RegisterForm, ArticleForm from functools import wraps data = Articles() def router(app, database): #index @app.route('/') def index(): return render_template('home.html') #about @app.route('/about') def about(): return render_template('about.html') #list of articles @app.route('/articles') def articles(): #create a cursor connection = database.connect() cursor = connection.cursor() #Get results result = cursor.execute("SELECT * FROM articles")
#cursor=conn.cursor() @app.route('/Home') def index(): return render_template('Home.html') #contacts @app.route('/contacts') def contact(): return render_template('contact_us.html') #All articles data_articles = Articles() @app.route('/Articles') def articles(): return render_template('articles.html', articles=data_articles) #single article @app.route('/article/<string:id>/') def article_sub(id): return render_template('article.html', id=id) class RegisterForm(Form): name = StringField('Name', [validators.Length(min=1, max=50)])