Git Product home page Git Product logo

microblog-api's Introduction

microblog-api

Build status codecov

A modern (as of 2022) Flask API back end.

Deploy to Heroku

Click the button below to deploy the application directly to your Heroku account.

Deploy

Deploy on your Computer

Setup

Follow these steps if you want to run this application on your computer, either in a Docker container or as a standalone Python application.

git clone https://github.com/miguelgrinberg/microblog-api
cd microblog-api
cp .env.example .env

Open the new .env file and enter values for the configuration variables.

Run with Docker

To start:

docker-compose up -d

The application runs on port 5000 on your Docker host. You can access the API documentation on the /docs URL (i.e. http://localhost:5000/docs if you are running Docker locally).

To populate the database with some randomly generated data:

docker-compose run --rm microblog-api bash -c "flask fake users 10 && flask fake posts 100"

To stop the application:

docker-compose down

Run locally

Set up a Python 3 virtualenv and install the dependencies on it:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Create the database and populate it with some randomly generated data:

flask db upgrade
flask fake users 10
flask fake posts 100

Run the application with the Flask development web server:

flask run

The application runs on localhost:5000. You can access the API documentation at http://localhost:5000/docs.

Troubleshooting

On macOS Monterey and newer, Apple decided to use port 5000 for its AirPlay service, which means that the Microblog API server will not be able to run on this port. There are two possible ways to solve this problem:

  1. Disable the AirPlay Receiver service. To do this, open the System Preferences, go to "Sharing" and uncheck "AirPlay Receiver".
  2. Move Microblog API to another port:
    • If you are running Microblog API with Docker, add a MICROBLOG_API_PORT=4000 line to your .env file. Change the 4000 to your desired port number.
    • If you are running Microblog API with Python, start the server with the command flask run --port=4000.

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.