Giter Club home page Giter Club logo

fastapi-javascript's Introduction

FastAPI-JavaScript

Interactive web interface templates with jQuery and Python. The backend is a REST API in Python developed with FastAPI while the frontend uses simple HTML, CSS (mainly with Bulma), and JavaScript that sends requests to the REST API and retrieves data responses.

Purpose

This repository includes minimal working examples to help create interactive web interfaces that require JavaScript events such as input change or clicking a word. It should also help build a basic REST API.

Note: In this sense, please note that the Python files use very simple examples that you should replace with your own model.

Auto-Suggest

The auto-suggest demo generates word suggestions as you type. Among use cases of this template are writing assistances, spelling checking, and interactive machine translation. Suggestions are triggered by a space as illustrated by this screenshot. Autosuggest

To try the auto-suggest example:

  1. install the Python packages in requirements.txt
pip3 install -r requirements.txt
  1. in the Terminal, navigate to the project's folder, and then run the command:
uvicorn app:app --reload
  1. open autosuggest.html in your browser (tested on Chrome and Safari);
  2. test it by typing a few words and pressing a space; this should trigger a list of suggestions. When you click a suggestion, it replaces the last word with it.

To edit the Python code, you have two parts whose comment starts with "Place here the code...". Use the first part for general functions and code that should be loaded only once, while the second part inside the complete() function should include the code that takes the input text, preprocesses it, uses the prefix to get the rest of the text, etc. The current function returns "prefix" as a string, and "suggestions" as a list of strings.

Acknowledgements

  • The jQuery plugin textarea-caret-position is used to get the coordinates of the caret in a textarea.
  • A portion of the dataset of the most frequent words in English unigram_freq.csv is used for demonstration purposes in the Python code.

Questions

If you have questions, feel free to contact me.

fastapi-javascript's People

Contributors

ymoslem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.