Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/ustjay-ethay-actsfayig.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: python main.py
web: python main.py runserver 0.0.0.0:6787
36 changes: 27 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
import os
"""a simple app to serve up pig latin"""

import os
import requests
from flask import Flask, send_file, Response
from flask import Flask, send_file, Response, render_template
from bs4 import BeautifulSoup

app = Flask(__name__)
FACT_URL = 'http://unkno.com'
PIG_LATINIZER_URL = 'https://hidden-journey-62459.herokuapp.com/piglatinize/'


def get_fact():
""" get the pig latin """

response = requests.get("http://unkno.com")

response = requests.get(FACT_URL)
soup = BeautifulSoup(response.content, "html.parser")
facts = soup.find_all("div", id="content")

return facts[0].getText()
pig_latin_prhase = facts[0].getText().strip()
return pig_latin_prhase


@app.route('/')
def home():
return "FILL ME!"
"""main functionality"""

my_fact = get_fact()
fact_dict = {'input_text': my_fact}
print(fact_dict)

pig_latin_response = requests.post(PIG_LATINIZER_URL,
allow_redirects=False,
data=fact_dict)
print(pig_latin_response.headers)
pig_latin_location = pig_latin_response.headers['Location']
print('test_' + pig_latin_location)
content = f"""
<div style='width:350px; text-align: center;margin-left:50px'>{my_fact}</div>
<p><b>Translate: </b><a href="{pig_latin_location}">{pig_latin_location}</a></p>"""
return render_template('pig_latin_translator.jinja2', body=content)


if __name__ == "__main__":
port = int(os.environ.get("PORT", 6787))
app.run(host='0.0.0.0', port=port)

app.run(host='0.0.0.0', port=port) # heroku
#app.run(host='localhost', port=port) # local
12 changes: 12 additions & 0 deletions requirements.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
beautifulsoup4==4.6.0
certifi==2018.4.16
chardet==3.0.4
click==6.7
Flask==1.0.1
idna==2.6
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.1.1
requests==2.18.4
urllib3==1.22
Werkzeug==0.14.1
23 changes: 23 additions & 0 deletions static/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
body {
font-family: "Calibri", "Helvetica", "sans-serif";
}
h1 {
font-size: 1.313em;
}

h2 {
font-size: 0.9167em;

p {
font-size: 0.9167em;
}
input {
font-size: 0.9167em;
}
input {
font-size: 0.9167em;
}
}
a:link {
text-decoration: none;
}
14 changes: 14 additions & 0 deletions templates/base.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<title>Random Facts in Pig Latin</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">

</head>
<body style='margin-left:10px'>
<h1>Pig Latin Translator</h1>
{% block content %} {% endblock content %}
<nav>
<a id="home" href="{{url_for('home')}}">-reload new fact-</a>
</nav>
</body>
</html>
4 changes: 4 additions & 0 deletions templates/pig_latin_translator.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% extends 'base.jinja2' %}
{% block content %}
<p>{{body}}</p>
{% endblock content %}