77 lines
1.6 KiB
Python
77 lines
1.6 KiB
Python
# all the imports
|
|
from __future__ import with_statement
|
|
from contextlib import closing
|
|
import sqlite3
|
|
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash, jsonify
|
|
import requests
|
|
from bs4 import BeautifulSoup
|
|
import re
|
|
from email.mime.text import MIMEText
|
|
from subprocess import Popen, PIPE
|
|
import smtplib
|
|
|
|
# configuration
|
|
DATABASE = '/tmp/dysprosium.db'
|
|
DEBUG = True
|
|
SECRET_KEY = 'development key'
|
|
USERNAME = 'admin'
|
|
PASSWORD = 'dupa.8'
|
|
|
|
app = Flask(__name__)
|
|
app.config.from_object(__name__)
|
|
|
|
|
|
def connect_db():
|
|
return sqlite3.connect(app.config['DATABASE'])
|
|
|
|
def init_db():
|
|
with closing(connect_db()) as db:
|
|
with app.open_resource('schema.sql') as f:
|
|
db.cursor().executescript(f.read())
|
|
db.commit()
|
|
|
|
@app.before_request
|
|
def before_request():
|
|
g.db = connect_db()
|
|
|
|
@app.teardown_request
|
|
def teardown_request(exception):
|
|
g.db.close()
|
|
|
|
@app.route('/')
|
|
def home():
|
|
return render_template('sencha.html')
|
|
|
|
@app.route('/examples')
|
|
def examples():
|
|
return render_template('examples.html')
|
|
|
|
@app.route('/docs')
|
|
def docs():
|
|
return render_template('documentation.html')
|
|
|
|
@app.route('/source')
|
|
def source():
|
|
return render_template('source.html')
|
|
|
|
@app.route('/contact')
|
|
def contact():
|
|
return render_template('contact.html')
|
|
|
|
@app.route('/howtos')
|
|
def howtos():
|
|
return render_template('howtos.html')
|
|
|
|
|
|
|
|
|
|
#this api is broken and inconsistent, I don't like it, mayby it'd be better to start with something different soon?
|
|
#a95ae api key for word reference is: a95ae
|
|
#http://www.wordreference.com/docs/api.aspx
|
|
|
|
|
|
if __name__ == '__main__':
|
|
init_db()
|
|
app.run()
|
|
|