Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
21 lines (18 sloc)
498 Bytes
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
import os | |
import uuid | |
import json | |
from flask import Flask, request, jsonify | |
from flask_cors import CORS | |
app = Flask(__name__) | |
CORS(app) | |
@app.route('/', methods=['POST']) | |
def store_print(): | |
fname = uuid.uuid4() | |
with open(f"to_print/{fname.hex}", 'w') as of: | |
of.write(json.dumps(request.json)) | |
return "we'll get right on that" | |
@app.before_first_request | |
def create_dirs(): | |
for path in ['to_print', 'printed']: | |
if not os.path.exists(path): | |
os.mkdir(path) |