-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d0de33
commit 0e43b69
Showing
10 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
WTF_CSRF_ENABLED = True | ||
SECRET_KEY = 'scrambled-eggs' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from flask import Flask | ||
from flask_bootstrap import Bootstrap | ||
|
||
app = Flask(__name__) | ||
app.config.from_object('config') | ||
bootstrap = Bootstrap(app) | ||
|
||
from flaskr import views |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from flask_wtf import FlaskForm | ||
from wtforms import StringField, SelectField | ||
from wtforms.validators import DataRequired, URL | ||
|
||
|
||
class MyInputBox(FlaskForm): | ||
uri = StringField("uri", validators=[URL()]) | ||
subject = StringField("subject") | ||
language = SelectField( | ||
u"Choose language", | ||
choices=[ | ||
("ttl", "ttl"), | ||
("xml", "rdf/xml"), | ||
("json-ld", "json-ld"), | ||
("nt", "ntriples"), | ||
], | ||
validators=[DataRequired()], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{# ``base.html`` is the template all our other templates derive from. While | ||
Flask-Bootstrap ships with its own base, it is good form to create a custom | ||
one for our app, as it allows customizing some aspects. | ||
|
||
Deriving from bootstap/base.html gives us a basic page scaffoling. | ||
|
||
You can find additional information about template inheritance at | ||
|
||
http://jinja.pocoo.org/docs/templates/#template-inheritance | ||
#} | ||
{%- extends "bootstrap/base.html" %} | ||
|
||
{# We also set a default title, usually because we might forget to set one. | ||
In our sample app, we will most likely just opt not to change it #} | ||
{% block title %}Sample App for Flask-Bootstrap{% endblock %} | ||
|
||
{# While we are at it, we also enable fixes for legacy browsers. First we | ||
import the necessary macros: #} | ||
{% import "bootstrap/fixes.html" as fixes %} | ||
|
||
{# Then, inside the head block, we apply these. To not replace the header, | ||
``super()`` is used: #} | ||
{% block head %} | ||
{{super()}} | ||
|
||
{#- Docs: http://pythonhosted.org/Flask-Bootstrap/macros.html#fixes | ||
The sample application already contains the required static files. #} | ||
{{fixes.ie8()}} | ||
{%- endblock %} | ||
|
||
{# Adding our own CSS files is also done here. Check the documentation at | ||
http://pythonhosted.org/Flask-Bootstrap/basic-usage.html#available-blocks | ||
for an overview. #} | ||
{% block styles -%} | ||
{{super()}} {# do not forget to call super or Bootstrap's own stylesheets | ||
will disappear! #} | ||
<link rel="stylesheet" type="text/css" | ||
href="{{url_for('static', filename='sample-app.css')}}"> | ||
{% endblock %} | ||
|
||
{# Finally, round things out with navigation #} | ||
{% block navbar %} | ||
{{nav.frontend_top.render()}} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{% extends "bootstrap/base.html" %} | ||
{% block title %}This is an example page{% endblock %} | ||
|
||
{% block navbar %} | ||
<div class="navbar navbar-fixed-top"> | ||
<!-- ... --> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="formwrapper"> | ||
<h1>RDF Inquisitor</h1> | ||
<form action="/" method="post" name="search" class="navbar-form navbar-left"> | ||
<div class="form-group"> | ||
{{ form.uri(class="form-control", size=50, placeholder="Specify URI") }} | ||
{{ form.language()}} | ||
</div> | ||
{{ form.submit }} | ||
<input type="submit" value="Go"> | ||
</form> | ||
</div> | ||
{% if results %} | ||
{{results}} | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from flaskr import app | ||
from flask import render_template, request, Markup | ||
from inquisitor.question import RDFInquisitor | ||
from pygments import highlight | ||
from pygments.formatters import HtmlFormatter | ||
from pygments.lexers.rdf import TurtleLexer | ||
from .forms import MyInputBox | ||
|
||
|
||
@app.route('/', methods=['GET', 'POST']) | ||
@app.route('/index', methods=['GET', 'POST']) | ||
def index(): | ||
form = MyInputBox(request.form) | ||
if request.method == 'POST': | ||
#print(form.language.data) | ||
print(form.subject.data) | ||
code = RDFInquisitor(form.uri.data).flaskerize_rdf(form.language.data) | ||
results = highlight(code, TurtleLexer(), HtmlFormatter(linenos=True, style="colorful", full=True)) | ||
return render_template('test.html', results=Markup(results), form=form) | ||
else: | ||
return render_template("test.html", form=form) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from flaskr import app | ||
import os | ||
|
||
port = int(os.getenv('PORT', 8080)) | ||
host = os.getenv('IP', '0.0.0.0') | ||
app.run(host=host, port=port, debug=True) | ||
|