Skip to content

Commit 8fd32c5

Browse files
committed
Template
1 parent 5aa3c77 commit 8fd32c5

File tree

7 files changed

+124
-2
lines changed

7 files changed

+124
-2
lines changed

.github/workflows/main.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: GITHUB CI
4+
5+
# Controls when the action will run. Triggers the workflow on push or pull request
6+
# events but only for the master branch
7+
on:
8+
push:
9+
branches: [ master ]
10+
pull_request:
11+
branches: [ master ]
12+
13+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
14+
jobs:
15+
build:
16+
runs-on: ubuntu-18.04
17+
# Steps represent a sequence of tasks that will be executed as part of the job
18+
steps:
19+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
20+
- uses: actions/checkout@v2
21+
with:
22+
python-version: '3.7.4'
23+
# Runs a set of commands using the runners shell
24+
- name: Setup Python Dependencies and Lint
25+
run: |
26+
pip3 install -r requirements.txt

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,41 @@
1-
# python-api-boilerplate
2-
A flask based Python API boiler plate. General purpose API with API key security
1+
![GITHUB CI](https://github.com/manoharuss/python-api-example/workflows/GITHUB%20CI/badge.svg?branch=master)
2+
3+
# python-api-example
4+
5+
A flask based simple Python API example.
6+
7+
## Setup
8+
9+
**Python version**
10+
11+
```
12+
13+
$ python --version
14+
15+
Python 3.7.4
16+
17+
$ pip --version
18+
19+
pip 20.1.1 from /Users/username/env/lib/python3.7/site-packages/pip (python 3.7)
20+
21+
```
22+
23+
**Install dependencies**
24+
25+
```sh
26+
27+
$ pip install -r requirements.txt
28+
29+
```
30+
31+
**Start app**
32+
33+
```
34+
35+
npm run lint
36+
37+
npm start
38+
39+
```
40+
41+
Head over to http://0.0.0.0:80/ for seeing locally served README.md.

api/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import markdown
2+
import os
3+
4+
# Import the framework
5+
from flask import Flask
6+
7+
# Create an instance of Flask
8+
app = Flask(__name__)
9+
10+
# At the very start of the page, just show the rendered markdown
11+
@app.route("/")
12+
def index():
13+
"""Present some documentation"""
14+
15+
# Open the README file
16+
with open(os.path.dirname(app.root_path) + "/README.md", "r") as markdown_file:
17+
18+
# Read the content of the file
19+
content = markdown_file.read()
20+
21+
# Convert to HTML
22+
return markdown.markdown(content)

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "python-api-example",
3+
"version": "1.0.0",
4+
"description": "A python API example",
5+
"main": "python run.py",
6+
"scripts": {
7+
"test": "npm run lint",
8+
"lint": "black . && flake8 . --ignore=E501,E302",
9+
"start": "python run.py"
10+
},
11+
"keywords": [
12+
"python",
13+
"python",
14+
"api",
15+
"example",
16+
"python",
17+
"template",
18+
"api",
19+
"template"
20+
],
21+
"license": "MIT"
22+
}

requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Flask==1.1.2
2+
flask-restful==0.3.8
3+
flake8==3.8.3
4+
markdown==3.2.2
5+
black==19.10b0

run.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from api import app
2+
3+
app.run(host="0.0.0.0", port=80, debug=True)

0 commit comments

Comments
 (0)