InfiniteWebsite/src/app.py

44 lines
1.3 KiB
Python

from flask import Flask, render_template
"""
This application is not written well I know. Its just a simple thing I threw together pretty quickly.
Environment to set:
OPENAI_API_KEY="sk-your-key-blahblahblah"
SQLITE_DB="/path/to/the/sqlite/database"
"""
app = Flask(__name__)
def getPageContent(route) -> str:
"""
Fetch the content of the provided page, either from the database or openai
"""
pass
@app.route("/<path:route>")
def default(route):
content = ""
for i in range(0, 1000):
content += "Test test test\n";
return render_template('base.html',
path=route,
content=content)
@app.route("/")
def baseRoute():
content = """
<p>An infinite website!</p>
<p>Type a url above and it will return a site generated by an AI!</p>
<p>The AI guesses what should be at the provided path, and returns it to you.</p>
<p>The pages will contain links generated by the AI. They will also work.</p>
<p>Pages someone else generated will be cached and served to you.</p>
<p>The site has a limit of 10 dollars a month of openai usage, or 100 pages a day. Be courtious if others want to use the site!</p>
"""
return render_template('base.html', path="/", content=content)