GET /api/v1/resource/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import re | |
def read_env(): | |
"""Pulled from Honcho code with minor updates, reads local default | |
environment variables from a .env file located in the project root | |
directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm i axios csv-parser | |
const axios = require('axios'); | |
const csv = require('csv-parser'); | |
const fs = require('fs'); | |
const authHeader = '' | |
const instance = axios.create({ | |
baseURL: 'http://<HOST>/api/v1', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
import gridfs | |
import base64 | |
import sys | |
import bson | |
import json | |
import os.path | |
save_path = "./files" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id": { | |
"$oid": "5d1bb7a420471bc4ba7d502e" | |
}, | |
"files_id": { | |
"$oid": "5d1bb79d20471bc4ba7d502d" | |
}, | |
"n": { | |
"$numberInt": "0" | |
}, |
So mongodb stores every document in the form of bson. A bson document has a max limit of 16 MB. Therefore mongodb uses something known as gridFS when saving huge files. It creates fs.chunks for storing base64 files and fs.files to store file metadata.
mongodump creates a dump of the whole DB. Like a bson snapshot. But due to version changes we have to run it in a docker container which has mongoDB 4.0 installed. It shows permission denied while creating a file. So I just exec'ed into the container to run the mongodump command.
docker run --rm -v $(pwd):/workdir/ -w /workdir/ mongo:4.0 mongodump -h server -d $database --out /workdir/dump/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (h *Handler) Ping(c echo.Context) error { | |
err := h.bulkops.Hello.CallPingTask("santhosh") | |
if err != nil { | |
return c.JSON(400, err) | |
} | |
return c.NoContent(http.StatusOK) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Model struct { | |
BatchID string `json:"batchID" bson:"batchID"` | |
OrgID string `json: "orgID" bson:"orgID"` | |
Tasks []Task `json:"tasks" bson:"tasks"` | |
Type string `json:"type" bson:"type"` | |
CreatedBy string `json:"createdBy" bson:"createdBy"` | |
State string `json:"state" bson:"state"` | |
UnitID string `json:"unitID" bson:"unitID"` | |
FileMeta FileMetaStruct `json:"fileMeta", bson:"fileMeta"` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Attaching a servepage function to the /host endpoint to handle post request | |
func (h Host) servepage(w http.ResponseWriter, r \*http.Request) { | |
err := r.ParseForm() | |
if err != nil { | |
log.Println(err) | |
} | |
f := r.Form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controller | |
import ( | |
"html/template" | |
) | |
type Host struct { | |
temp \*template.Template | |
} |