Skip to content

Instantly share code, notes, and snippets.

@NilsIrl
Forked from MatejMecka/main.py
Created April 9, 2020 20:06
Show Gist options
  • Save NilsIrl/bc036be93f22696f9376572e2f096cbd to your computer and use it in GitHub Desktop.
Save NilsIrl/bc036be93f22696f9376572e2f096cbd to your computer and use it in GitHub Desktop.
"""
main.py
That's it this is the entire API.
"""
from flask import Flask, jsonify
import markovify
app = Flask(__name__)
with open("nietzche.txt") as f:
text = f.read()
text_model = markovify.Text(text)
@app.route('/')
def api():
"""
<>/
The Main view for the API
return: JSON from markovify
"""
sentence = text_model.make_sentence()
return jsonify({"quote":sentence})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment