Giter Site home page Giter Site logo

newsle-backend's Introduction

Newsle backend

The backend of Newsle, an API, created with Flask, which calls the news API and edits the data for usage by my frontend.

Running

Run python newsle_api.py to get the headline normally.

Test commands have the format:
python newsle_api.py "<test_headline>"
Example:
python newsle_api.py "Earth invaded by Martians"

newsle-backend's People

Contributors

jackfrancismurphy avatar

Watchers

Jack Daniel Harding avatar  avatar

newsle-backend's Issues

Move IP address used for CORS header to properties file

Description
Currently when Deploying the App you need to edit the newdle_api.py file to make the IP address in the CORS header equal to the IP address of the machine it's running on.
A better solution would be to have this IP address or URL retrieved from a properties file (e.g. newdle.properties, newdle.ini, etc)

Acceptance Criteria
URL is no longer hardcoded in any python scripts
A separate properties file exists in the repo storing the URL needed for the cors header. (this can be defaulted to the existing localhost value)

Add scambling to Newdle API

Requirements

  • The Returned data includes a scambled version of that headline which isn't hardcoded

If this is working and the scramble isn't hardcoded then each time the endpoint is called the scramble should be different

Add argument to script for passing hardcoded headline

Currently the backend is run using:
python newdle_api.py
This ticket is to change the code so that the first argument passed to the script will be used as a hardcoded headline, rather than using the headline from the API.
e.g.

python newdle_api.py "My test headlline"

This will be used for testing when the API is unavailable

Store a headline of the day in the Python backend

The API call will be nested in a conditional statement. If the headline of the day is not set then the API call is made. If it is set then the API call simply grab's a new variable called 'the day's headline'.

(But how will each day be differentiated in the code?)

Inverted commas in the headline mess up the game.

Keyboards seem to only have straight commas like this '', they don't have the specific '6', '9' inverted commas. Therefore, those commas have to be changed into the straight ones before being sent to the front end

Create basic Newdle API

Requirements
Create API with an endpoint which takes a GET request and returns a hardcoded scramble

backend is not externally visible

Description
Currently when you run the python flask API it only runs for the local machine meaning that it cannot be accessed externally.

To fix that you need to update the line.
app.run()

to instead be
app.run(host='0.0.0.0')

How to recreate
Try to access the API endpoint from your external IP address rather than localhost

Notes
I recommend doing some research on flask / flask-restful to fully understand what this argument does

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.