Skip to content

Instantly share code, notes, and snippets.

@MatejMecka
Created July 2, 2018 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save MatejMecka/3c5ab2abc21632e7951acdc700efa896 to your computer and use it in GitHub Desktop.
Save MatejMecka/3c5ab2abc21632e7951acdc700efa896 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