Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask_cors import cross_origin
- from flask import (
- Flask,
- request,
- abort,
- render_template,
- )
- from waitress import serve
- from word_scraper import Word
- app = Flask(
- __name__,
- template_folder='build',
- static_folder='build'
- )
- @app.route('/', strict_slashes=False)
- def main_page() -> str:
- html_page = render_template('index.html')
- return html_page
- @app.route(f"/api/<word>")
- @cross_origin()
- def index(word):
- word_to_give = Word(word).get_raw(
- no_mongo_id=True,
- schema="API"
- )
- if word_to_give == None:
- word_to_give = {}
- return word_to_give
- if __name__ == '__main__':
- serve(app, port=80, host='cdict.ru')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement