Code Monkey home page Code Monkey logo

tempy's Introduction

Tempy : Temporary File Storage in Python

This is a simple file management application that allows users to upload and download temporary files from any terminal using curl or wget. The backend is built using FastAPI with SQLAlchemy for database management, and the frontend is built using Streamlit. The application supports user authentication and each user has their own directory on the server.

Features

  • User registration and authentication
  • File upload and download
  • File space checking for each user
  • Streamlit frontend for user interaction
  • Backend API with FastAPI
  • SQLite database with SQLAlchemy
  • Dockerized using Docker Compose

Project Structure

project/
│
├── backend/
│   ├── main.py
│   ├── models.py
│   ├── crud.py
│   ├── database.py
│   ├── security.py
│   ├── schemas.py
│   ├── Dockerfile
│   └── .env
│
├── frontend/
│   ├── app.py
│   ├── Dockerfile
│   └── .env
│
├── docker-compose.yml
└── .env

Installation

Prerequisites

  • Docker
  • Docker Compose

Steps

  1. Clone the repository:

    git clone https://github.com/yourusername/file-management-app.git
    cd file-management-app
  2. Create a .env file in the root directory and add the following environment variables:

    SECRET_KEY=your-secret-key
    SUPER_ADMIN_USERNAME=admin
    SUPER_ADMIN_PASSWORD=adminpassword
  3. Navigate to the backend directory and create a .env file with the following content:

    SECRET_KEY=your-secret-key
    SUPER_ADMIN_USERNAME=admin
    SUPER_ADMIN_PASSWORD=adminpassword
  4. Navigate to the frontend directory and create a .env file with the following content:

    API_URL=http://backend:8000
  5. Build and start the application using Docker Compose:

    docker-compose up --build

Usage

Access the Frontend

  • Open your browser and navigate to http://localhost:8501 to access the Streamlit frontend.

Using the API

Register a new user

curl -X POST "http://localhost:8000/users/" -H "Content-Type: application/json" -d '{"username": "testuser", "email": "[email protected]", "full_name": "Test User", "password": "testpassword"}'

Login and get token

curl -X POST "http://localhost:8000/token" -d "username=testuser&password=testpassword"

Upload a file

curl -X POST "http://localhost:8000/upload" -H "Authorization: Bearer <your_token>" -F "file=@<path_to_your_file>"

Download a file

curl -X GET "http://localhost:8000/download/<filename>" -H "Authorization: Bearer <your_token>" -O

Check file space

curl -X GET "http://localhost:8000/filespace" -H "Authorization: Bearer <your_token>"

API Endpoints

  • POST /users/: Register a new user
  • POST /token: Obtain a JWT token
  • POST /upload: Upload a file
  • GET /download/{filename}: Download a file
  • GET /filespace: Check available file space and list files

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Acknowledgements


tempy's People

Contributors

prembamrung avatar

Watchers

 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.