Commit 267fde3a authored by Ishan Patel's avatar Ishan Patel Committed by Mitchell Moore
Browse files

Created temp dir for fb to store user data info. Fixed timestamp format

- Created temp_path for db
- Code cleanup- fixed whitespaces
- Fixed time_stamp format
- Added-mkdir-function
parent c9fec8d8
......@@ -7,14 +7,11 @@ import os
import os.path
import sys
import time
import datetime
import subprocess
# third-party imports
from flask import Flask, redirect, url_for, request, render_template, flash
from flask_wtf import FlaskForm
from flask_bootstrap import Bootstrap
from wtforms import StringField, SubmitField, validators
def create_app(config_name):
......@@ -25,27 +22,20 @@ def create_app(config_name):
global return_url
return_url = ''
class MainForm(FlaskForm):
fullname = StringField('Full Name: ', [validators.DataRequired(), ])
submit = SubmitField('Submit')
@app.route('/', methods=['GET', 'POST'])
def index():
global return_url
user = request.remote_user
if "redir" in request.args and return_url == "":
return_url = request.args.get("redir") or "/pun/sys/dashboard"
username = False
form = MainForm()
if form.is_submitted():
username = = ''
if name != "":
return redirect(url_for('success', username=str(user), fullname=username))
return redirect(url_for('success', username=str(user), fullname=name))
return render_template('auth/SignUp.html', form=form, user=user)
return render_template("auth/SignUp.html", user=user)
def success(username, fullname):
......@@ -58,17 +48,23 @@ def create_app(config_name):
print(tempString, file=sys.stdout)
time_stamp = time.strftime("%Y%m%d-%H%M%S")
blazer_path = "/var/www/ood/register/flask_user_reg"
complete_file_name = os.path.join(blazer_path, time_stamp+".txt")
# function to write out a flatdb with the name of the file being a timestamp and the content
# of the file beieng blazerID the user submitted from the flask form (fullname)
time_stamp = time.strftime("%m-%d-%Y_%H:%M:%S")
directory = "/var/www/ood/register/flask_user_reg/app/flat_db"
complete_file_name = os.path.join(directory, time_stamp + ".txt")
if not os.path.exists(directory):
file = open(complete_file_name, "w")
return redirect(return_url, 302)
flash("Registration Failed. Please try again.")
return redirect(url_for('index'))
flash("Registration Failed")
return redirect(return_url)
def forbidden(error):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment