start fleshing out more of meme uploader
parent
566f631bf6
commit
c9bc600b3a
@ -1,8 +1,50 @@
|
||||
from flask import Blueprint
|
||||
import ipfsApi
|
||||
from os import path
|
||||
from secrets import token_urlsafe
|
||||
from json import loads, dumps
|
||||
|
||||
from flask import Blueprint, render_template, request, current_app
|
||||
|
||||
|
||||
bp = Blueprint('meta', 'meta')
|
||||
|
||||
@bp.route('/')
|
||||
@bp.route('/', methods=['GET', 'POST'])
|
||||
def index():
|
||||
return 'interplanetary memes'
|
||||
if "file" in request.files:
|
||||
title = request.form.get('title')
|
||||
description = request.form.get('description')
|
||||
creator = request.form.get('creator')
|
||||
file = request.files["file"]
|
||||
filename = "{}{}".format(
|
||||
token_urlsafe(24),
|
||||
path.splitext(file.filename)[1]
|
||||
)
|
||||
file.save(filename)
|
||||
try:
|
||||
client = ipfsApi.Client('127.0.0.1', 5001)
|
||||
artwork_hash = client.add(filename)['Hash']
|
||||
client.pin_add(artwork_hash)
|
||||
print(f'[+] Uploaded artwork to IPFS: {artwork_hash}')
|
||||
# Create meta json
|
||||
meta = {
|
||||
'name': title,
|
||||
'description': description,
|
||||
'image': f'ipfs://{artwork_hash}',
|
||||
'by': creator,
|
||||
'properties': {
|
||||
'creator': creator
|
||||
}
|
||||
}
|
||||
print(meta)
|
||||
meta_hash = client.add_json(meta)
|
||||
client.pin_add(meta_hash)
|
||||
print(f'[+] Uploaded metadata to IPFS: {meta_hash}')
|
||||
except ConnectionError:
|
||||
print('[!] Unable to connect to local ipfs')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return render_template('index.html')
|
||||
|
||||
@bp.route('/next')
|
||||
def next():
|
||||
return render_template('next.html')
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>SuchWowX!</title>
|
||||
<script src="https://unpkg.com/unpoly@2.5.0/unpoly.min.js"></script>
|
||||
<link rel="stylesheet" href="https://unpkg.com/unpoly@2.5.0/unpoly.min.css">
|
||||
<link rel="stylesheet" href="/static/css/bulma.min.css">
|
||||
<link rel="stylesheet" href="/static/css/bulma.css.map">
|
||||
</head>
|
||||
<body>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title">
|
||||
SuchwowX. <br/>
|
||||
|
||||
</h1>
|
||||
<p class="subtitle">
|
||||
Memes. <strong>Interplanetary</strong>!
|
||||
</p>
|
||||
|
||||
<!-- <a href="/next" class="one" up-target=".one">
|
||||
Flip
|
||||
</a>
|
||||
|
||||
<a href="/next" class="two" up-target=".two">
|
||||
Flip
|
||||
</a> -->
|
||||
|
||||
<form method="POST" enctype="multipart/form-data" class="site-form" id="memeUpload">
|
||||
<div class="field">
|
||||
<label class="label">File</label>
|
||||
<div class="control">
|
||||
<input class="filestyle" id="file" name="file" required type="file">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label">Title</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" placeholder="Title of your meme" name="title">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label">Creator</label>
|
||||
<div class="control">
|
||||
<input class="input" type="text" placeholder="Your handle" name="creator">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label">Description</label>
|
||||
<div class="control">
|
||||
<textarea class="textarea" placeholder="Description..." name="description"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="control">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox">
|
||||
I agree to support the ongoing funding of exploratory meme missions
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<button class="button is-primary">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://unpkg.com/unpoly@2.5.0/unpoly.min.js"></script>
|
||||
<link rel="stylesheet" href="https://unpkg.com/unpoly@2.5.0/unpoly.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<!-- HTML here may use Unpoly attributes like [up-follow] -->
|
||||
<a href="/" class="one" up-target=".one">
|
||||
♥
|
||||
</a>
|
||||
|
||||
<a href="/" class="two" up-target=".two">
|
||||
♠
|
||||
</a>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue