Skip to content

tngaspar/webpage-archive-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

main page

Webpage Archive Webapp + API

A CRUD webapp that allows users to log in and save webpage urls. It also allow for archiving pages on the WayBackMachine so that the content is available even if the orginal page is taken down.

Checkout a live demo of the webapp here.

How it works

  • User signs up or logs in with chosen username and password. Password is hashed using bycrypt and stored in a Deta noSQL database. A temporary access token is also generated, using JWT each time the user logs in/signs up and it is saved as a browser cookie (valid for 4h or until user logs out).
  • A new page is saved by filling up the form request on "Save a new page". By clicking save a POST request is sent to the API built with FastAPI. The API then validates if the url format is valid and inserts the new webpage on the database.
  • By pressing "Archive" in a saved webpage a call is made to the WayBackMachine to archive the url. If successful the "Archive" button will display "Go to archive" and the database record will be updated with the archive url.

Installation

Clone the repo:

$ git clone https://github.com/tngaspar/webpage-archive-api.git

Install dependencies. I advice the use of a virtual environment for isolation.

$ pip install -r requirements.txt

Create a Deta account and install deta Space CLI.

Add a config.py file in the project root directory with:

# config.py
deta_private_key = '********************************************'
db_user_secret_key = '********************************************'

Get deta_private_key by creating a collection on Deta Space and choose a db_user_secret_key (used to generate access tokens).

The app can now be initiated:

- Locally with uvicorn:

$ uvicorn main:app --reload

and accessed at http://localhost:8000/

- On Deta:

$ deta new
$ deta push

This will create an instance of the app only visible to you. If you want to make the app publicly accessible add

# Spacefile
micro:
    ...
    public_routes:
      - "/*"

to the Spacefile created by the commands above.

Requirements

(back to top)