work on lan server (upload endpoint)
This commit is contained in:
parent
e6181bdd1f
commit
3e4a39016f
@ -5,15 +5,16 @@ LAN transport server thread
|
|||||||
from gevent.pywsgi import WSGIServer
|
from gevent.pywsgi import WSGIServer
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask import Response
|
from flask import Response
|
||||||
from gevent import sleep
|
from flask import request
|
||||||
|
|
||||||
from onionrblocks.onionrblockapi import Block
|
from onionrblocks.onionrblockapi import Block
|
||||||
from httpapi.fdsafehandler import FDSafeHandler
|
from httpapi.fdsafehandler import FDSafeHandler
|
||||||
from netcontroller import get_open_port
|
from netcontroller import get_open_port
|
||||||
import config
|
import config
|
||||||
from coredb.blockmetadb import get_block_list
|
from coredb.blockmetadb import get_block_list
|
||||||
from lan.getip import lan_ips, best_ip
|
from lan.getip import best_ip
|
||||||
from onionrutils import stringvalidators
|
from onionrutils import stringvalidators
|
||||||
|
from httpapi.miscpublicapi.upload import accept_upload
|
||||||
"""
|
"""
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -48,12 +49,17 @@ class LANServer:
|
|||||||
def get_block_data(block):
|
def get_block_data(block):
|
||||||
if not stringvalidators.validate_hash(block):
|
if not stringvalidators.validate_hash(block):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
return Response(Block(block).raw, mimetype='application/octet-stream')
|
return Response(
|
||||||
|
Block(block).raw, mimetype='application/octet-stream')
|
||||||
|
|
||||||
@app.route("/ping")
|
@app.route("/ping")
|
||||||
def ping():
|
def ping():
|
||||||
return Response("pong!")
|
return Response("pong!")
|
||||||
|
|
||||||
|
@app.route('/upload', methods=['POST'])
|
||||||
|
def upload_endpoint():
|
||||||
|
return accept_upload(request)
|
||||||
|
|
||||||
def start_server(self):
|
def start_server(self):
|
||||||
self.server = WSGIServer((self.host, get_open_port()),
|
self.server = WSGIServer((self.host, get_open_port()),
|
||||||
self.app, log=None,
|
self.app, log=None,
|
||||||
|
Loading…
Reference in New Issue
Block a user